From e2cbed7dbdf46315a3d6965e134783bf0b5b50a8 Mon Sep 17 00:00:00 2001 From: DavoudTaghawiNejad Date: Sun, 10 Sep 2017 17:27:54 -0300 Subject: [PATCH 1/8] Let plugins overwrite the __init__ method --- abce/__init__.py | 6 +++++- abce/agent.py | 2 +- docs/plugins.rst | 16 ++++++++++++---- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/abce/__init__.py b/abce/__init__.py index a54e2770..8b156343 100644 --- a/abce/__init__.py +++ b/abce/__init__.py @@ -461,7 +461,9 @@ def build_agents(self, AgentClass, group_name, number=None, agent_args={'group': group_name, 'trade_logging': self.trade_logging_mode, 'database': self.database_queue, - 'random_seed': random.random()}, + 'random_seed': random.random(), + 'agent_parameters': agent_parameters, + 'simulation_parameters': parameters}, parameters=parameters, agent_parameters=agent_parameters, agent_params_from_sim=agent_params_from_sim) @@ -503,6 +505,8 @@ def create_agent(self, AgentClass, group_name, parameters=None, agent_parameters 'trade_logging': self.trade_logging_mode, 'database': self.database_queue, 'random_seed': random.random(), + 'agent_parameters': agent_parameters, + 'simulation_parameters': parameters, 'start_round': self.time}, parameters=parameters, agent_parameters=agent_parameters) diff --git a/abce/agent.py b/abce/agent.py index 0b6d375f..4e06a240 100644 --- a/abce/agent.py +++ b/abce/agent.py @@ -87,7 +87,7 @@ def return_quantity_of_good(self): """ def __init__(self, id, group, trade_logging, - database, random_seed, num_managers, start_round=None): + database, random_seed, num_managers, agent_parameters, simulation_parameters, start_round=None): """ Do not overwrite __init__ instead use a method called init instead. init is called whenever the agent are build. """ diff --git a/docs/plugins.rst b/docs/plugins.rst index c8387ab6..9ec17e2e 100644 --- a/docs/plugins.rst +++ b/docs/plugins.rst @@ -6,7 +6,8 @@ you want to author your own plugin - its dead simple. All you have to do is write a class that inherits from Agent in agent.py. This class can overwrite:: - def init(self, parameter, agent_parameter) + def __init__(self, id, group, trade_logging, database, random_seed, num_managers, + agent_parameters, simulation_parameters, start_round=None): def _begin_subround(self): def _end_subround(self): def _advance_round(self, time): @@ -14,14 +15,17 @@ This class can overwrite:: For example like this:: class UselessAgent(abce.Agent): - def init(self, parameter, agent_parameter): - super().init() + def __init__(self, id, group, trade_logging, + database, random_seed, num_managers, agent_parameters, + simulation_parameters, start_round=None): + super().__init__(id, group, trade_logging, + database, random_seed, num_managers, agent_parameters, + simulation_parameters, start_round=None): print("Here i begin") def _begin_subround(self): super()._begin_subround() print('subround begins') - print("its %r o'clock" % self.time) def _end_subround(self): super()._end_subround() @@ -32,4 +36,8 @@ For example like this:: print('Super I made it to the next round') def ability(self): + print("its %r o'clock" % self.time) print("the simulation called my ability") + + +**Do not overwrite the init(parameters, simulation_parameters)** method From f1d1c7bc063ab9cd8195b97c9f0b1e2c064d8a85 Mon Sep 17 00:00:00 2001 From: DavoudTaghawiNejad Date: Sun, 10 Sep 2017 18:56:06 -0300 Subject: [PATCH 2/8] Postpone checking for enreceived messages or offers to the end, except when check_unchecked_msgs flag is set to True --- abce/__init__.py | 12 ++++++++++-- abce/agent.py | 33 +++++++++++++++++++++------------ docs/plugins.rst | 12 +++++++----- unittest/start.py | 2 +- 4 files changed, 39 insertions(+), 20 deletions(-) diff --git a/abce/__init__.py b/abce/__init__.py index 8b156343..b3ee8256 100644 --- a/abce/__init__.py +++ b/abce/__init__.py @@ -106,6 +106,9 @@ class Simulation(object): **For easy debugging set processes to 1, this way only one agent runs at a time and only one error message is displayed** + check_unchecked_msgs: + check every round that all messages have been received with get_massages or get_offers. + Example:: simulation = Simulation(name='ABCE', @@ -150,7 +153,7 @@ class Simulation(object): """ def __init__(self, name='abce', random_seed=None, - trade_logging='off', processes=1): + trade_logging='off', processes=1, check_unchecked_msgs=False): """ """ try: @@ -158,6 +161,8 @@ def __init__(self, name='abce', random_seed=None, except NameError: pass + self.check_unchecked_msgs = check_unchecked_msgs + self.num_of_agents_in_group = {} self._messages = {} self._resource_command_group = {} @@ -386,6 +391,7 @@ def finalize(self): print('') print(str("time only simulation %6.2f" % (time.time() - self.clock))) + self.database_queue.put('close') while self._db.is_alive(): @@ -463,7 +469,8 @@ def build_agents(self, AgentClass, group_name, number=None, 'database': self.database_queue, 'random_seed': random.random(), 'agent_parameters': agent_parameters, - 'simulation_parameters': parameters}, + 'simulation_parameters': parameters, + 'check_unchecked_msgs': self.check_unchecked_msgs}, parameters=parameters, agent_parameters=agent_parameters, agent_params_from_sim=agent_params_from_sim) @@ -507,6 +514,7 @@ def create_agent(self, AgentClass, group_name, parameters=None, agent_parameters 'random_seed': random.random(), 'agent_parameters': agent_parameters, 'simulation_parameters': parameters, + 'check_unchecked_msgs': self.check_unchecked_msgs, 'start_round': self.time}, parameters=parameters, agent_parameters=agent_parameters) diff --git a/abce/agent.py b/abce/agent.py index 4e06a240..2d2a64da 100644 --- a/abce/agent.py +++ b/abce/agent.py @@ -87,7 +87,8 @@ def return_quantity_of_good(self): """ def __init__(self, id, group, trade_logging, - database, random_seed, num_managers, agent_parameters, simulation_parameters, start_round=None): + database, random_seed, num_managers, agent_parameters, simulation_parameters, + check_unchecked_msgs, start_round=None): """ Do not overwrite __init__ instead use a method called init instead. init is called whenever the agent are build. """ @@ -113,7 +114,6 @@ def __init__(self, id, group, trade_logging, # TODO make defaultdict; delete all key errors regarding self._haves as # defaultdict, does not have missing keys - self._haves['money'] = 0 self._msgs = {} self.given_offers = OrderedDict() @@ -153,6 +153,8 @@ def __init__(self, id, group, trade_logging, self.log_this_round = True + self._check_every_round_for_lost_messages = check_unchecked_msgs + def init(self, parameters, agent_parameters): """ This method is called when the agents are build. It can be overwritten by the user, to initialize the agents. @@ -191,7 +193,7 @@ def _offer_counter(self): self._offer_count += 1 return hash((self.name, self._offer_count)) - def _advance_round(self, time): + def _check_for_lost_messages(self): for offer in list(self.given_offers.values()): if offer.made < self.round: print("in agent %s this offers have not been retrieved:" % @@ -203,15 +205,6 @@ def _advance_round(self, time): 'last round and not been retrieved in this' 'round get_offer(.)' % (self.group, self.id)) - self._haves._advance_round() - self.contracts._advance_round(self.round) - - if self.trade_logging > 0: - self.database_connection.put( - ["trade_log", self._trade_log, self.round]) - - self._trade_log = defaultdict(int) - if sum([len(offers) for offers in list(self._open_offers_buy.values())]): pprint(dict(self._open_offers_buy)) raise Exception('%s_%i: There are offers an agent send that have ' @@ -230,6 +223,13 @@ def _advance_round(self, time): 'have not been retrieved in this round ' 'get_messages(.)' % (self.group, self.id)) + def _advance_round(self, time): + self._haves._advance_round() + self.contracts._advance_round(self.round) + + if self._check_every_round_for_lost_messages: + self._check_for_lost_messages() + for ingredient, units, product in self._resources: self._haves.create(product, self.possession(ingredient) * units) @@ -245,6 +245,12 @@ def _advance_round(self, time): else: self.log_this_round = False + if self.trade_logging > 0: + self.database_connection.put( + ["trade_log", self._trade_log, self.round]) + + self._trade_log = defaultdict(int) + def create(self, good, quantity): """ creates quantity of the good out of nothing @@ -353,3 +359,6 @@ def _send(self, receiver_group, receiver_id, typ, msg): def __getitem__(self, good): return self._haves[good] + + def __del__(self): + self._check_for_lost_messages() diff --git a/docs/plugins.rst b/docs/plugins.rst index 9ec17e2e..6e7f29ec 100644 --- a/docs/plugins.rst +++ b/docs/plugins.rst @@ -7,7 +7,8 @@ have to do is write a class that inherits from Agent in agent.py. This class can overwrite:: def __init__(self, id, group, trade_logging, database, random_seed, num_managers, - agent_parameters, simulation_parameters, start_round=None): + agent_parameters, simulation_parameters, + check_unchecked_msgs, start_round=None): def _begin_subround(self): def _end_subround(self): def _advance_round(self, time): @@ -15,12 +16,13 @@ This class can overwrite:: For example like this:: class UselessAgent(abce.Agent): - def __init__(self, id, group, trade_logging, - database, random_seed, num_managers, agent_parameters, - simulation_parameters, start_round=None): + def __init__(self, id, group, trade_logging, database, random_seed, num_managers, + agent_parameters, simulation_parameters, + check_unchecked_msgs, start_round=None): super().__init__(id, group, trade_logging, database, random_seed, num_managers, agent_parameters, - simulation_parameters, start_round=None): + simulation_parameters, check_unchecked_msgs, + start_round): print("Here i begin") def _begin_subround(self): diff --git a/unittest/start.py b/unittest/start.py index d5db20a5..5e8f233e 100644 --- a/unittest/start.py +++ b/unittest/start.py @@ -7,7 +7,7 @@ start_logging_test.main(processes=1) print('Iteration of logger testing with 1 core finished') - if (platform.system() != 'Windows'): + if (platform.system() != 'Windows' and platform.python_implementation() != 'PyPy'): start_logging_test.main(processes=4) print('Iteration of logger testing with multiple processes finished') From ca17c77859bc2f513f82bbf5176b18e84e5fd1e7 Mon Sep 17 00:00:00 2001 From: DavoudTaghawiNejad Date: Sun, 10 Sep 2017 19:01:51 -0300 Subject: [PATCH 3/8] Message can be accessed by getitem --- abce/messaging.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/abce/messaging.py b/abce/messaging.py index e2b72c56..22895c4a 100644 --- a/abce/messaging.py +++ b/abce/messaging.py @@ -32,6 +32,9 @@ def __init__(self, sender, receiver, topic, content): self.topic = topic self.content = content + def __getitem__(self, item): + return self.content[item] + def __repr__(self): return "<{sender: %s; receiver: %s; topic: %s; content: %s}>" % ( str(self.sender), str(self.receiver), self.topic, str(self.content)) From 01ab8f759ff9328777c9756c2806bf7e1eb35924 Mon Sep 17 00:00:00 2001 From: DavoudTaghawiNejad Date: Sun, 10 Sep 2017 19:04:13 -0300 Subject: [PATCH 4/8] Fix flexiblecontracting.py --- abce/contracts/flexiblecontracting.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abce/contracts/flexiblecontracting.py b/abce/contracts/flexiblecontracting.py index 5ef70392..f2fa267e 100644 --- a/abce/contracts/flexiblecontracting.py +++ b/abce/contracts/flexiblecontracting.py @@ -7,7 +7,7 @@ from random import shuffle from abce.trade import get_epsilon from .contracts import Contracts -from .contract import Contract +from .contracting import Contract epsilon = get_epsilon() From 9dcc198c92e326c599ac1aa53471d4c503dc6ea9 Mon Sep 17 00:00:00 2001 From: DavoudTaghawiNejad Date: Sun, 10 Sep 2017 22:48:19 -0300 Subject: [PATCH 5/8] Delete multicurrencytrade.pyx --- abce/compile.py | 3 +- abce/multicurrencytrade.pyx | 566 ------------------------------------ 2 files changed, 1 insertion(+), 568 deletions(-) delete mode 100644 abce/multicurrencytrade.pyx diff --git a/abce/compile.py b/abce/compile.py index 6591e3a6..5b87853c 100644 --- a/abce/compile.py +++ b/abce/compile.py @@ -13,7 +13,6 @@ name='trade', ext_modules=[ Extension('trade', ['trade.pyx']), - Extension('online_variance', ['online_variance.pyx']), - Extension('multicurrencytrade', ['multicurrencytrade.pyx'])], + Extension('online_variance', ['online_variance.pyx'])], cmdclass={'build_ext': build_ext} ) diff --git a/abce/multicurrencytrade.pyx b/abce/multicurrencytrade.pyx deleted file mode 100644 index bbd11810..00000000 --- a/abce/multicurrencytrade.pyx +++ /dev/null @@ -1,566 +0,0 @@ -# Copyright 2012 Davoud Taghawi-Nejad -# -# Module Author: Davoud Taghawi-Nejad -# -# ABCE is open-source software. If you are using ABCE for your research you are -# requested the quote the use of this software. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License and quotation of the -# author. You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -The :class:`abceagent.Agent` class is the basic class for creating your agent. It automatically handles the -possession of goods of an agent. In order to produce/transforme goods you need to also subclass -the :class:`abceagent.Firm` [1]_ or to create a consumer the :class:`abceagent.Household`. - -For detailed documentation on: - -Trading: - see :class:`abceagent.Trade` -Logging and data creation: - see :class:`abceagent.Database` and :doc:`simulation_results` -Messaging between agents: - see :class:`abceagent.Messaging`. - -.. autoexception:: abcetools.NotEnoughGoods - -.. [1] or :class:`abceagent.FirmMultiTechnologies` for simulations with complex technologies. -""" -#******************************************************************************************# -# trade.pyx is written in cython. When you modify trade.pyx you need to compile it with # -# compile.sh and compile.py because the resulting trade.c file is distributed. # -# Don't forget to commit it to git # -#******************************************************************************************# -from __future__ import division -from abce.trade import Trade, get_epsilon -from abce.notenoughgoods import NotEnoughGoods -from abce.messaging import Message -import random - -cdef double epsilon = 0.00000000001 - - -cdef double fmax(double a, double b): - if a > b: - return a - else: - return b - - -cdef class Offer: - """ This is an offer container that is send to the other agent. You can - access the offer container both at the receiver as well as at the sender, - if you have saved the offer. (e.G. self.offer = self.sell(...)) - - it has the following properties: - sender_group: - this is the group name of the sender - - sender_id: - this is the ID of the sender - - receiver_group: - This is the group name of the receiver - - receiver_id: - this is the ID of the sender - - good: - the good offered or demanded - - quantity: - the quantity offered or demanded - - price: - the suggested tansaction price - - buysell: - this can have the values 'b' for buy; 's' for sell; 'qb' for a - nonbinding buy quote; and 'qs' for a nonbinding sell quote - - status: - 'new': - has been created, but not answered - - 'accepted': - trade fully accepted - - 'rejected': - trade rejected - - 'pending': - offer has not yet answered, and is not older than one round. - - 'perished': - the **perishable** good was not accepted by the end of the round - and therefore perished. - - final_quantity: - If the offer has been answerd this returns the actual quantity - bought or sold. (Equal to quantity if the offer was accepted fully) - id: - a unique identifier - """ - cdef readonly str sender_group - cdef readonly int sender_id - cdef readonly str receiver_group - cdef readonly int receiver_id - cdef readonly str good - cdef readonly str currency - cdef readonly double quantity - cdef readonly double price - cdef readonly char buysell - cdef public str status - cdef public double final_quantity - cdef readonly object id - cdef readonly int made - cdef public str open_offer_status - cdef public int status_round - - def __cinit__(self, str sender_group, int sender_id, str receiver_group, - int receiver_id, str good, str currency, double quantity, double price, - char buysell, str status, double final_quantity, long id, - int made, str open_offer_status, int status_round): - self.sender_group = sender_group - self.sender_id = sender_id - self.receiver_group = receiver_group - self.receiver_id = receiver_id - self.good = good - self.currency = currency - self.quantity = quantity - self.price = price - self.buysell = buysell - self.status = status - self.final_quantity = final_quantity - self.id = id - self.made = made - self.open_offer_status = open_offer_status - self.status_round = status_round - - def pickle(self): - return (self.sender_group, self.sender_id, self.receiver_group, - self.receiver_id, self.good, self.currency, self.quantity, self.price, - self.buysell, self.status, self.final_quantity, self.id, - self.made, self.open_offer_status, self.status_round) - - def __repr__(self): - return """<{sender: %s, %i, receiver_group: %s, - receiver_id: %i, good: %s, currency: %s, quantity: %f, price: %f, - buysell: %s, status: %s, final_quantity: % f, id: %i, - made: %i, open_offer_status: % s, status_round: %i }>""" % ( - - self.sender_group, self.sender_id, self.receiver_group, - self.receiver_id, self.good, self.currency, self.quantity, self.price, - self.buysell, self.status, self.final_quantity, self.id, - self.made, self.open_offer_status, self.status_round) - -class MultiCurrencyTrade(Trade): - """ This class replaces the :class:`abceagent.Trade` class if you have multiple currencies or barter, - just overload the all agents with the MultiCurrencyTrade class. In one simulation you can use either - MultiCurrencyTrade or Trade so all agent groups in one simulation need to inherit from MultiCurrencyTrade - or Trade. - - Agents can trade with each other. The clearing of the trade is taken care - of fully by ABCE. - Selling a good works in the same way as in :class:`abceagent.Trade`: - - 1. An agent sends an offer. :meth:`~.sell` - - *The good offered is blocked and self.possession(...) does shows the decreased amount.* - - 2. **Next subround:** An agent receives the offer :meth:`~.get_offers`, and can - :meth:`~.accept`, :meth:`~.reject` or partially accept it. :meth:`~.accept` - - *The good is credited and the price is deducted from the agent's possessions.* - - 3. **Next subround:** - - - in case of acceptance *the money is automatically credited.* - - in case of partial acceptance *the money is credited and part of the blocked good is unblocked.* - - in case of rejection *the good is unblocked.* - - Analogously for buying: :meth:`~.buy` - - Example:: - - # Agent 1 - def sales(self): - self.remember_trade = self.sell('Household', 0, 'cookies', quantity=5, price=self.price, currency='dollars') - - # Agent 2 - def receive_sale(self): - oo = self.get_offers('cookies') - for offer in oo: - if ((offer.currency == 'dollars' and offer.price < 0.3 * exchange_rate) - or (offer.currency == 'euros' and dollars'offer.price < 0.3)): - - try: - self.accept(offer) - except NotEnoughGoods: - self.accept(offer, self.possession('money') / offer.price) - else: - self.reject(offer) - - If we did not implement a barter class, but one can use this class as a barter class, - using the currency as the second good e.G:: - - self.remember_trade = self.sell('Household', 0, good='cookies', currency='wheels' quantity=5, price=self.price, ) - - """ - - - def sell(self, receiver_group, receiver_id, - good, double quantity, double price, currency='money', double epsilon=epsilon): - """ commits to sell the quantity of good at price - - The good is not available for the agent. When the offer is - rejected it is automatically re-credited. When the offer is - accepted the money amount is credited. (partial acceptance - accordingly) - - Args: - receiver_group: - group of the receiving agent - - receiver_id: - number of the receiving agent - - 'good': - name of the good - - quantity: - maximum units disposed to buy at this price - - price: - price per unit - - currency: - is the currency of this transaction (defaults to 'money') - - epsilon (optional): - if you have floating point errors, a quantity or prices is - a fraction of number to high or low. You can increase the - floating point tolerance. See troubleshooting -- floating point problems - - Returns: - A reference to the offer. The offer and the offer status can - be accessed with `self.info(offer_reference)`. - - Example:: - - def subround_1(self): - self.offer = self.sell('household', 1, 'cookies', quantity=5, price=0.1) - - def subround_2(self): - offer = self.info(self.offer) - if offer.status == 'accepted': - print(offer.final_quantity , 'cookies have be bougth') - else: - offer.status == 'rejected': - print('On diet') - """ - cdef double available - assert price > - epsilon, 'price %.30f is smaller than 0 - epsilon (%.30f)' % (price, - epsilon) - if price < 0: - price = 0 - # makes sure the quantity is between zero and maximum available, but - # if its only a little bit above or below its set to the bounds - available = self._haves[good] - assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) - if quantity < 0: - quantity = 0 - if quantity > available + epsilon + epsilon * fmax(quantity, available): - raise NotEnoughGoods(self.name, good, quantity - available) - if quantity > available: - quantity = available - - offer_id = self._offer_counter() - self._haves[good] -= quantity - cdef Offer offer = Offer(self.group, - self.id, - receiver_group, - receiver_id, - good, - currency, - quantity, - price, - 115, - 'new', - -2, - offer_id, - self.round, - '-', - -2) - self.given_offers[offer_id] = offer - self._send(receiver_group, receiver_id, '_o', offer.pickle()) - return offer - - def buy(self, receiver_group, receiver_id, good, - double quantity, double price, currency, double epsilon=epsilon): - """ commits to sell the quantity of good at price - - The goods are not in haves or self.count(). When the offer is - rejected it is automatically re-credited. When the offer is - accepted the money amount is credited. (partial acceptance - accordingly) - - Args: - receiver_group: - group of the receiving agent - - receiver_id: - number of the receiving agent - - 'good': - name of the good - - quantity: - maximum units disposed to buy at this price - - price: - price per unit - - currency: - is the currency of this transaction (defaults to 'money') - - epsilon (optional): - if you have floating point errors, a quantity or prices is - a fraction of number to high or low. You can increase the - floating point tolerance. See troubleshooting -- floating point problems - """ - cdef double available - cdef double money_amount - assert price > - epsilon, 'price %.30f is smaller than 0 - epsilon (%.30f)' % (price, - epsilon) - if price < 0: - price = 0 - money_amount = quantity * price - # makes sure the money_amount is between zero and maximum available, but - # if its only a little bit above or below its set to the bounds - available = self._haves[currency] - assert money_amount > - epsilon, '%s (price * quantity) %.30f is smaller than 0 - epsilon (%.30f)' % (currency, money_amount, - epsilon) - if money_amount < 0: - money_amount = 0 - if money_amount > available + epsilon + epsilon * fmax(money_amount, available): - raise NotEnoughGoods(self.name, currency, money_amount - available) - if money_amount > available: - money_amount = available - - offer_id = self._offer_counter() - self._haves[currency] -= money_amount - cdef Offer offer = Offer(self.group, - self.id, - receiver_group, - receiver_id, - good, - quantity, - price, - 98, - 'new', - -1, - offer_id, - self.round, - '', - -1) - self._send(receiver_group, receiver_id, '_o', offer.pickle()) - self.given_offers[offer_id] = offer - return offer - - - def accept(self, Offer offer, double quantity=-999, double epsilon=epsilon): - """ The buy or sell offer is accepted and cleared. If no quantity is - given the offer is fully accepted; If a quantity is given the offer is - partial accepted - - Args: - - offer: - the offer the other party made - quantity: - quantity to accept. If not given all is accepted - - epsilon (optional): - if you have floating point errors, a quantity or prices is - a fraction of number to high or low. You can increase the - floating point tolerance. See troubleshooting -- floating point problems - - Return: - Returns a dictionary with the good's quantity and the amount paid. - """ - cdef double money_amount - cdef double offer_quantity = offer.quantity - cdef double available - - if quantity == -999: - quantity = offer_quantity - assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) - if quantity < 0: - quantity = 0 - if quantity > offer_quantity + epsilon * fmax(quantity, offer_quantity): - raise AssertionError('accepted more than offered %s: %.100f >= %.100f' - % (offer.good, quantity, offer_quantity)) - if quantity > offer_quantity: - quantity = offer_quantity - - if quantity == 0: - self.reject(offer) - return {offer.good: 0, offer.currency: 0} - - money_amount = quantity * offer.price - if offer.buysell == 115: # ord('s') - assert money_amount > - epsilon, 'money = quantity * offer.price %.30f is smaller than 0 - epsilon (%.30f)' % (money_amount, - epsilon) - if money_amount < 0: - money_amount = 0 - - available = self._haves[offer.currency] - if money_amount > available + epsilon + epsilon * max(money_amount, available): - raise NotEnoughGoods(self.name, offer.currency, money_amount - available) - if money_amount > available: - money_amount = available - self._haves[offer.good] += quantity - self._haves[offer.currency] -= quantity * offer.price - else: - assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) - if quantity < 0: - quantity = 0 - available = self._haves[offer.good] - if quantity > available + epsilon + epsilon * max(quantity, available): - raise NotEnoughGoods(self.name, offer.good, quantity - available) - if quantity > available: - quantity = available - self._haves[offer.good] -= quantity - self._haves[offer.currency] += quantity * offer.price - offer.final_quantity = quantity - self._send(offer.sender_group, offer.sender_id, '_p', (offer.id, quantity)) - del self._open_offers[offer.good][offer.id] - if offer.buysell == 115: # ord('s') - return {offer.good: - quantity, offer.currency: money_amount} - else: - return {offer.good: quantity, offer.currency: - money_amount} - - - - # def _log_receive_accept_group(self, Offer offer): - # if offer.buysell == 115: - # self._trade_log['%s,%s,%s,%f' % (offer.good, self.group, offer.receiver_group, offer.price)] += offer.quantity - # else: - # self._trade_log['%s,%s,%s,%f' % (offer.good, offer.receiver_group, self.group, offer.price)] += offer.quantity - - # def _log_receive_accept_agent(self, Offer offer): - # if offer.buysell == 115: - # self._trade_log['%s,%s,%s,%f' % (offer.good, self.name_without_colon, '%s_%i' % (offer.receiver_group, offer.receiver_id), offer.price)] += offer.quantity - # else: - # self._trade_log['%s,%s,%s,%f' % (offer.good, '%s_%i' % (offer.receiver_group, offer.receiver_id), self.name_without_colon, offer.price)] += offer.quantity - - def _receive_accept(self, offer_id_final_quantity): - """ When the other party partially accepted the money or good is - received, remaining good or money is added back to haves and the offer - is deleted - """ - cdef Offer offer = self.given_offers[offer_id_final_quantity[0]] - offer.final_quantity = offer_id_final_quantity[1] - if offer.buysell == 115: - self._haves[offer.currency] += offer.final_quantity * offer.price - self._haves[offer.good] += offer.quantity - offer.final_quantity - else: - self._haves[offer.good] += offer.final_quantity - self._haves[offer.currency] += (offer.quantity - offer.final_quantity) * offer.price - offer.status = "accepted" - offer.status_round = self.round - del self.given_offers[offer.id] - return offer - - # def _log_receive_accept_group(self, Offer offer): - # if offer.buysell == 115: - # self._trade_log['%s,%s,%s,%f' % (offer.good, self.group, offer.receiver_group, offer.price)] += offer.final_quantity - # else: - # self._trade_log['%s,%s,%s,%f' % (offer.good, offer.receiver_group, self.group, offer.price)] += offer.final_quantity - - # def _log_receive_accept_agent(self, Offer offer): - # if offer.buysell == 115: - # self._trade_log['%s,%s,%s,%f' % (offer.good, self.name_without_colon, '%s_%i' % (offer.receiver_group, offer.receiver_id), offer.price)] += offer.final_quantity - # else: - # self._trade_log['%s,%s,%s,%f' % (offer.good, '%s_%i' % (offer.receiver_group, offer.receiver_id), self.name_without_colon, offer.price)] += offer.final_quantity - - def _receive_reject(self, offer_id): - """ delets a given offer - - is used by _msg_clearing__end_of_subround, when the other party rejects - or at the end of the subround when agent retracted the offer - - """ - cdef Offer offer = self.given_offers[offer_id] - if offer.buysell == 115: - self._haves[offer.good] += offer.quantity - else: - self._haves[offer.currency] += offer.quantity * offer.price - offer.status = "rejected" - offer.status_round = self.round - offer.final_quantity = 0 - del self.given_offers[offer_id] - - def _delete_given_offer(self, offer_id): - cdef Offer offer = self.given_offers.pop(offer_id) - if offer.buysell == 115: - self._haves[offer.good] += offer.quantity - else: - self._haves[offer.currency] += offer.quantity * offer.price - - def _clearing__end_of_subround(self, incomming_messages): - """ agent receives all messages and objects that have been send in this - subround and deletes the offers that where retracted, but not executed. - - '_o': registers a new offer - '_d': delete received that the issuing agent retract - '_p': clears a made offer that was accepted by the other agent - '_r': deletes an offer that the other agent rejected - '_g': recive a 'free' good from another party - """ - cdef Offer offer - for typ, msg in incomming_messages: - if typ == '_o': - offer = Offer(*msg) - offer.open_offer_status ='received' - self._open_offers[offer.good][offer.id] = offer - elif typ == '_d': - del self._open_offers[msg.good][msg.id] - elif typ == '_p': - offer = self._receive_accept(msg) - if self.trade_logging == 2: - self._log_receive_accept_group(offer) - elif self.trade_logging == 1: - self._log_receive_accept_agent(offer) - elif typ == '_r': - self._receive_reject(msg) - elif typ == '_g': - self._haves[msg[0]] += msg[1] - elif typ == '_q': - self._quotes[msg.id] = msg - elif typ == '!o': - self._contract_offers[msg.good].append(msg) - elif typ == '_ac': - contract = self._contract_offers_made[msg.id] - if contract.pay_group == self.group and contract.pay_id == self.id: - self._contracts_pay[contract.good][contract.id] = contract - else: - self._contracts_deliver[contract.good][contract.id] = contract - elif typ == '_dp': - if msg.pay_group == self.group and msg.pay_id == self.id: - self._haves[msg.good] += msg.quantity - self._contracts_pay[msg.good][msg.id].delivered.append(self.round) - else: - self._haves[offer.currency] += msg.quantity * msg.price - self._contracts_deliver[msg.good][msg.id].paid.append(self.round) - - elif typ == '!d': - if msg[0] == 'r': - del self._contracts_pay[msg[1]][msg[2]] - if msg[0] == 'd': - del self._contracts_deliver[msg[1]][msg[2]] - else: - self._msgs.setdefault(typ, []).append(msg) From 6d8237127208f7259a311f1766f652e21adbf2c0 Mon Sep 17 00:00:00 2001 From: DavoudTaghawiNejad Date: Sun, 10 Sep 2017 23:05:05 -0300 Subject: [PATCH 6/8] Reserve goods instead of substracting them when makeing an offer --- abce/agent.py | 36 +- abce/agents/firmmultitechnologies.py | 20 +- abce/agents/household.py | 12 +- abce/database.py | 16 +- abce/inventory.py | 59 +- abce/trade.c | 4063 ++++++++++++++------------ abce/trade.py | 88 +- abce/trade.pyx | 59 +- setup.py | 2 +- unittest/buy.py | 32 +- unittest/buyexpiringcapital.py | 19 +- unittest/contractbuyer.py | 15 +- unittest/contractbuyerstop.py | 23 +- unittest/contractseller.py | 16 +- unittest/contractsellerstop.py | 25 +- unittest/endowment.py | 13 +- unittest/expiringcapital.py | 12 +- unittest/give.py | 11 +- unittest/giveexpiringcapital.py | 18 +- unittest/production_firm.py | 62 +- unittest/production_multifirm.py | 65 +- unittest/quote_buy.py | 19 +- unittest/sell.py | 42 +- unittest/start.py | 8 +- unittest/utility_household.py | 34 +- 25 files changed, 2509 insertions(+), 2260 deletions(-) diff --git a/abce/agent.py b/abce/agent.py index 2d2a64da..f54dfef4 100644 --- a/abce/agent.py +++ b/abce/agent.py @@ -36,7 +36,6 @@ from .database import Database from .trade import Trade from .messaging import Messaging -from .expiringgood import ExpiringGood from .inventory import Inventory @@ -68,7 +67,7 @@ def selling(self): ... def return_quantity_of_good(self): - return possession('good') + return['good'] ... @@ -110,9 +109,9 @@ def __init__(self, id, group, trade_logging, self.num_managers = num_managers self._out = [[] for _ in range(self.num_managers + 1)] - self._haves = Inventory(self.name) + self._inventory = Inventory(self.name) - # TODO make defaultdict; delete all key errors regarding self._haves as + # TODO make defaultdict; delete all key errors regarding self._inventory as # defaultdict, does not have missing keys self._msgs = {} @@ -174,18 +173,19 @@ def possession(self, good): Example:: - if self.possession('money') < 1: + if self['money'] < 1: self.financial_crisis = True - if not(is_positive(self.possession('money')): + if not(is_positive(self['money']): self.bancrupcy = True """ - return self._haves.possession(good) + print("depreciated use self[good]") + return self._inventory[good] def possessions(self): """ returns all possessions """ - return self._haves.possessions() + return self._inventory.possessions() def _offer_counter(self): """ returns a unique number for an offer (containing the agent's name) @@ -224,14 +224,14 @@ def _check_for_lost_messages(self): 'get_messages(.)' % (self.group, self.id)) def _advance_round(self, time): - self._haves._advance_round() + self._inventory._advance_round() self.contracts._advance_round(self.round) if self._check_every_round_for_lost_messages: self._check_for_lost_messages() for ingredient, units, product in self._resources: - self._haves.create(product, self.possession(ingredient) * units) + self._inventory.create(product, self[ingredient] * units) self.round = time self.time = time @@ -261,7 +261,7 @@ def create(self, good, quantity): 'good': is the name of the good quantity: number """ - self._haves.create(good, quantity) + self._inventory.create(good, quantity) def create_timestructured(self, good, quantity): """ creates quantity of the time structured good out of nothing. @@ -287,13 +287,15 @@ def create_timestructured(self, good, quantity): quantity: an arry or number """ - self._haves.create_timestructured(good, quantity) + self._inventory.create_timestructured(good, quantity) def _declare_expiring(self, good, duration): """ creates a good that has a limited duration """ - self._haves[good] = ExpiringGood(duration) - self._haves._expiring_goods.append(good) + self._inventory._declare_expiring(good, duration) + + def free(self, good): + return self._inventory.free(good) def destroy(self, good, quantity=None): """ destroys quantity of the good. If quantity is omitted destroys all @@ -309,7 +311,7 @@ def destroy(self, good, quantity=None): NotEnoughGoods: when goods are insufficient """ - self._haves.destroy(good, quantity) + self._inventory.destroy(good, quantity) def _execute(self, command, args, kwargs): self._out = [[] for _ in range(self.num_managers + 1)] @@ -345,7 +347,7 @@ def _register_resource(self, resource, units, product): self._resources.append((resource, units, product)) def _register_perish(self, good): - self._haves._perishable.append(good) + self._inventory._perishable.append(good) def _send(self, receiver_group, receiver_id, typ, msg): """ sends a message to 'receiver_group', who can be an agent, a group or @@ -358,7 +360,7 @@ def _send(self, receiver_group, receiver_id, typ, msg): (receiver_group, receiver_id, (typ, msg))) def __getitem__(self, good): - return self._haves[good] + return self._inventory[good] def __del__(self): self._check_for_lost_messages() diff --git a/abce/agents/firmmultitechnologies.py b/abce/agents/firmmultitechnologies.py index fedcc24a..53d23cec 100644 --- a/abce/agents/firmmultitechnologies.py +++ b/abce/agents/firmmultitechnologies.py @@ -48,7 +48,7 @@ def produce_use_everything(self, production_function): self.produce_use_everything(car_production_function) """ - return self.produce(production_function, {inp: self.possession(inp) for inp in production_function['input']}) + return self.produce(production_function, {inp: self[inp] for inp in production_function['input']}) def produce(self, production_function, input_goods): """ Produces output goods given the specified amount of inputs. @@ -80,24 +80,24 @@ def produce(self, production_function, input_goods): """ if production_function.use == 'all': for good in list(input_goods.keys()): - if self._haves[good] < input_goods[good] - epsilon: + if self._inventory[good] < input_goods[good] - epsilon: raise NotEnoughGoods( - self.name, good, (input_goods[good] - self._haves[good])) + self.name, good, (input_goods[good] - self._inventory[good])) for good in input_goods: - self._haves[good] -= input_goods[good] + self._inventory.haves[good] -= input_goods[good] else: for good in list(production_function.use.keys()): - if self._haves[good] < input_goods[good] - epsilon: + if self._inventory[good] < input_goods[good] - epsilon: raise NotEnoughGoods( - self.name, good, (input_goods[good] - self._haves[good])) + self.name, good, (input_goods[good] - self._inventory[good])) for good, use in production_function.use.items(): - self._haves[good] -= input_goods[good] * use + self._inventory.haves[good] -= input_goods[good] * use output_dict = production_function.production(input_goods) for good in list(output_dict.keys()): - self._haves[good] += output_dict[good] + self._inventory.haves[good] += output_dict[good] return output_dict @@ -473,9 +473,9 @@ def predict_net_value(self, production_function, input_goods, price_vector): def sufficient_goods(self, input_goods): """ checks whether the agent has all the goods in the vector input """ for good in input_goods: - if self._haves[good] < input_goods[good] - epsilon: + if self._inventory[good] < input_goods[good] - epsilon: raise NotEnoughGoods( - self.name, good, input_goods[good] - self._haves[good]) + self.name, good, input_goods[good] - self._inventory[good]) class ProductionFunction(object): diff --git a/abce/agents/household.py b/abce/agents/household.py index 0e48789b..13aa7922 100644 --- a/abce/agents/household.py +++ b/abce/agents/household.py @@ -17,9 +17,7 @@ """ The Household class extends the agent by giving him utility functions and the ability to consume goods. """ -from __future__ import division -from __future__ import absolute_import -from builtins import object +from abce import NotEnoughGoods import operator from functools import reduce from ..trade import get_epsilon @@ -51,7 +49,7 @@ def consume_everything(self): utility = self.consume_everything() self.log('utility': {'u': utility}) """ - return self.consume({inp: self._haves[inp] for inp in list(self._utility_function.use.keys())}) + return self.consume({inp: self._inventory[inp] for inp in list(self._utility_function.use.keys())}) def consume(self, input_goods): """ consumes input_goods returns utility according to the agent's @@ -83,12 +81,12 @@ def consume(self, input_goods): """ for good in list(self._utility_function.use.keys()): - if self._haves[good] < input_goods[good] - epsilon: + if self._inventory[good] < input_goods[good] - epsilon: raise NotEnoughGoods( - self.name, good, (input_goods[good] - self._haves[good])) + self.name, good, (input_goods[good] - self._inventory[good])) for good, use in self._utility_function.use.items(): - self._haves[good] -= input_goods[good] * use + self._inventory.haves[good] -= input_goods[good] * use return self._utility_function.formula(input_goods) diff --git a/abce/database.py b/abce/database.py index 81d6d354..70246e13 100644 --- a/abce/database.py +++ b/abce/database.py @@ -61,8 +61,8 @@ def log(self, action_name, data_to_log): self.log('profit', profit) self.log('employment_and_rent', - {'employment': self.possession('LAB'), - 'rent': self.possession('CAP'), + {'employment': self['LAB'], + 'rent': self['CAP'], 'composite': self.composite}) self.log(self.produce_use_everything()) @@ -105,7 +105,7 @@ def log_change(self, action_name, data_to_log): Examples:: - self.log_change('profit', {'money': self.possession('money')]}) + self.log_change('profit', {'money': self['money']]}) self.log_change('inputs', {'money': self.possessions(['money', 'gold', 'CAP', 'LAB')]}) """ @@ -148,8 +148,8 @@ def observe_begin(self, action_name, data_to_observe): ... different method ... self.log('employment_and_rent', { - 'employment': self.possession('LAB'), - 'rent': self.possession('CAP')}) + 'employment': self['LAB'], + 'rent': self['CAP']}) """ if self.log_this_round: self._data_to_observe[action_name] = data_to_observe @@ -172,8 +172,8 @@ def observe_end(self, action_name, data_to_observe): ... different method ... self.log('employment_and_rent', { - 'employment': self.possession('LAB'), - 'rent':self.possession('CAP')}) + 'employment': self['LAB'], + 'rent':self['CAP']}) """ if self.log_this_round: before = self._data_to_observe.pop(action_name) @@ -190,7 +190,7 @@ def _common_log(self, variables, possessions, functions, lengths): for var in variables: ret[var] = self.__dict__[var] for pos in possessions: - ret[pos] = self._haves[pos] + ret[pos] = self._inventory[pos] for name, func in functions.items(): ret[name] = func(self) for length in lengths: diff --git a/abce/inventory.py b/abce/inventory.py index b2bf8940..1bfe28a7 100644 --- a/abce/inventory.py +++ b/abce/inventory.py @@ -1,15 +1,16 @@ from abce.trade import get_epsilon from collections import defaultdict from abce.notenoughgoods import NotEnoughGoods -from copy import copy +from .expiringgood import ExpiringGood epsilon = get_epsilon() -class Inventory(defaultdict): +class Inventory(object): def __init__(self, name): - super(Inventory, self).__init__(float) + self.haves = defaultdict(int) + self.committed = defaultdict(int) self.name = name self._expiring_goods = [] self._perishable = [] @@ -25,7 +26,7 @@ def create(self, good, quantity): quantity: number """ assert quantity >= 0.0 - self[good] += quantity + self.haves[good] += quantity def create_timestructured(self, good, quantity): """ creates quantity of the time structured good out of nothing. @@ -36,7 +37,7 @@ def create_timestructured(self, good, quantity): Creates capital. 10 units are 2 years old 20 units are 1 year old and 30 units are new. - It can alse be used with a quantity instead of an array. In this + It can also be used with a quantity instead of an array. In this case the amount is equally split on the years.:: self.creat_timestructured('capital', 60) @@ -51,10 +52,10 @@ def create_timestructured(self, good, quantity): quantity: an arry or number """ - length = len(self[good].time_structure) + length = len(self.haves[good].time_structure) for i in range(length): qty = quantity[i] if type(quantity) == list else quantity / length - self[good].time_structure[i] += qty + self.haves[good].time_structure[i] += qty def destroy(self, good, quantity=None): """ destroys quantity of the good. If quantity is omitted destroys all @@ -73,21 +74,38 @@ def destroy(self, good, quantity=None): NotEnoughGoods: when goods are insufficient """ if quantity is None: - self[good] = 0 + self.haves[good] = 0 else: assert quantity >= 0.0 - available = self[good] + available = self.haves[good] if available < quantity - epsilon: raise NotEnoughGoods(self.name, good, quantity - available) - self[good] -= quantity + self.haves[good] -= quantity + + def reserve(self, good, quantity): + self.committed[good] += quantity + if self.committed[good] > self.haves[good]: + self.committed[good] += quantity + raise NotEnoughGoods(self.name, good, quantity - (self.haves[good] - self.committed[good])) + + def rewind(self, good, quantity): + self.committed[good] -= quantity + + def commit(self, good, committed_quantity, final_quantity): + self.committed[good] -= committed_quantity + self.haves[good] -= final_quantity def transform(self, ingredient, unit, product, quantity=None): if quantity is None: - quantity = self[ingredient] + quantity = self.haves[ingredient] self.destroy(ingredient, quantity) self.create(product, float(unit) * quantity) def possession(self, good): + print('possession depreciated') + return self.free(good) + + def free(self, good): """ returns how much of good an agent possesses. Returns: @@ -98,18 +116,18 @@ def possession(self, good): Example:: - if self.possession('money') < 1: + if self['money'] < 1: self.financial_crisis = True - if not(is_positive(self.possession('money')): + if not(is_positive(self['money']): self.bankruptcy = True """ - return float(self[good]) + return float(self.haves[good] - self.committed[good]) def possessions(self): """ returns all possessions """ - return copy(super()) + return {good: float(self.haves[good] - self.committed[good]) for good in self.haves} def calculate_netvalue(self, prices): return sum(quantity * prices[name] @@ -140,9 +158,16 @@ def calculate_valued_liablities(self, prices): def _advance_round(self): # expiring goods for good in self._expiring_goods: - self[good]._advance_round() + self.haves[good]._advance_round() # perishing goods for good in self._perishable: - if good in self: + if good in self.haves: self.destroy(good) + + def __getitem__(self, good): + return self.haves[good] + + def _declare_expiring(self, good, duration): + self.haves[good] = ExpiringGood(duration) + self._expiring_goods.append(good) diff --git a/abce/trade.c b/abce/trade.c index dddc129f..77505875 100644 --- a/abce/trade.c +++ b/abce/trade.c @@ -658,7 +658,7 @@ struct __pyx_obj_5trade_Offer { }; -/* "trade.pyx":170 +/* "trade.pyx":173 * made, status_round) * * cdef class Trade: # <<<<<<<<<<<<<< @@ -1106,24 +1106,27 @@ static const char __pyx_k_send[] = "_send"; static const char __pyx_k_sort[] = "sort"; static const char __pyx_k_test[] = "__test__"; static const char __pyx_k_group[] = "group"; -static const char __pyx_k_haves[] = "_haves"; +static const char __pyx_k_haves[] = "haves"; static const char __pyx_k_money[] = "money"; static const char __pyx_k_offer[] = "offer"; static const char __pyx_k_price[] = "price"; static const char __pyx_k_round[] = "round"; static const char __pyx_k_trade[] = "trade"; static const char __pyx_k_append[] = "append"; +static const char __pyx_k_commit[] = "commit"; static const char __pyx_k_import[] = "__import__"; static const char __pyx_k_pay_id[] = "pay_id"; static const char __pyx_k_quotes[] = "_quotes"; static const char __pyx_k_random[] = "random"; static const char __pyx_k_reject[] = "reject"; +static const char __pyx_k_rewind[] = "rewind"; static const char __pyx_k_sorted[] = "sorted"; static const char __pyx_k_status[] = "status"; static const char __pyx_k_update[] = "update"; static const char __pyx_k_values[] = "values"; static const char __pyx_k_epsilon[] = "epsilon"; static const char __pyx_k_randint[] = "randint"; +static const char __pyx_k_reserve[] = "reserve"; static const char __pyx_k_reverse[] = "reverse"; static const char __pyx_k_shuffle[] = "shuffle"; static const char __pyx_k_accepted[] = "accepted"; @@ -1133,6 +1136,7 @@ static const char __pyx_k_receiver[] = "receiver"; static const char __pyx_k_rejected[] = "rejected"; static const char __pyx_k_shuffled[] = "shuffled"; static const char __pyx_k_delivered[] = "delivered"; +static const char __pyx_k_inventory[] = "_inventory"; static const char __pyx_k_pay_group[] = "pay_group"; static const char __pyx_k_sender_id[] = "sender_id"; static const char __pyx_k_trade_log[] = "_trade_log"; @@ -1193,6 +1197,7 @@ static PyObject *__pyx_kp_s_accepted_more_than_offered_s_100; static PyObject *__pyx_n_s_append; static PyObject *__pyx_kp_s_b; static PyObject *__pyx_n_s_buy; +static PyObject *__pyx_n_s_commit; static PyObject *__pyx_n_s_contract_offers; static PyObject *__pyx_n_s_contract_offers_made; static PyObject *__pyx_n_s_contracts_deliver; @@ -1219,6 +1224,7 @@ static PyObject *__pyx_n_s_group; static PyObject *__pyx_n_s_haves; static PyObject *__pyx_n_s_id; static PyObject *__pyx_n_s_import; +static PyObject *__pyx_n_s_inventory; static PyObject *__pyx_n_s_key; static PyObject *__pyx_n_s_keys; static PyObject *__pyx_n_s_log_receive_accept_agent; @@ -1266,7 +1272,9 @@ static PyObject *__pyx_n_s_receiver_group; static PyObject *__pyx_n_s_receiver_id; static PyObject *__pyx_n_s_reject; static PyObject *__pyx_n_s_rejected; +static PyObject *__pyx_n_s_reserve; static PyObject *__pyx_n_s_reverse; +static PyObject *__pyx_n_s_rewind; static PyObject *__pyx_n_s_round; static PyObject *__pyx_kp_s_s; static PyObject *__pyx_kp_s_s__i; @@ -1490,7 +1498,7 @@ static double __pyx_f_5trade_fmax(double __pyx_v_a, double __pyx_v_b) { return __pyx_r; } -/* "trade.pyx":124 +/* "trade.pyx":127 * cdef readonly object sender * * def __cinit__(self, str sender_group, int sender_id, str receiver_group, # <<<<<<<<<<<<<< @@ -1550,71 +1558,71 @@ static int __pyx_pw_5trade_5Offer_1__cinit__(PyObject *__pyx_v_self, PyObject *_ case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_sender_id)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 1); __PYX_ERR(0, 124, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 1); __PYX_ERR(0, 127, __pyx_L3_error) } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_receiver_group)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 2); __PYX_ERR(0, 124, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 2); __PYX_ERR(0, 127, __pyx_L3_error) } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_receiver_id)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 3); __PYX_ERR(0, 124, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 3); __PYX_ERR(0, 127, __pyx_L3_error) } case 4: if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_good)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 4); __PYX_ERR(0, 124, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 4); __PYX_ERR(0, 127, __pyx_L3_error) } case 5: if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_quantity)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 5); __PYX_ERR(0, 124, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 5); __PYX_ERR(0, 127, __pyx_L3_error) } case 6: if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_price)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 6); __PYX_ERR(0, 124, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 6); __PYX_ERR(0, 127, __pyx_L3_error) } case 7: if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_currency)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 7); __PYX_ERR(0, 124, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 7); __PYX_ERR(0, 127, __pyx_L3_error) } case 8: if (likely((values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_sell)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 8); __PYX_ERR(0, 124, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 8); __PYX_ERR(0, 127, __pyx_L3_error) } case 9: if (likely((values[9] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_status)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 9); __PYX_ERR(0, 124, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 9); __PYX_ERR(0, 127, __pyx_L3_error) } case 10: if (likely((values[10] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_final_quantity)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 10); __PYX_ERR(0, 124, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 10); __PYX_ERR(0, 127, __pyx_L3_error) } case 11: if (likely((values[11] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_id)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 11); __PYX_ERR(0, 124, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 11); __PYX_ERR(0, 127, __pyx_L3_error) } case 12: if (likely((values[12] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_made)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 12); __PYX_ERR(0, 124, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 12); __PYX_ERR(0, 127, __pyx_L3_error) } case 13: if (likely((values[13] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_status_round)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 13); __PYX_ERR(0, 124, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, 13); __PYX_ERR(0, 127, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 124, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 127, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 14) { goto __pyx_L5_argtuple_error; @@ -1635,32 +1643,32 @@ static int __pyx_pw_5trade_5Offer_1__cinit__(PyObject *__pyx_v_self, PyObject *_ values[13] = PyTuple_GET_ITEM(__pyx_args, 13); } __pyx_v_sender_group = ((PyObject*)values[0]); - __pyx_v_sender_id = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_sender_id == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 124, __pyx_L3_error) + __pyx_v_sender_id = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_sender_id == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 127, __pyx_L3_error) __pyx_v_receiver_group = ((PyObject*)values[2]); - __pyx_v_receiver_id = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_receiver_id == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 125, __pyx_L3_error) + __pyx_v_receiver_id = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_receiver_id == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 128, __pyx_L3_error) __pyx_v_good = values[4]; - __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 125, __pyx_L3_error) - __pyx_v_price = __pyx_PyFloat_AsDouble(values[6]); if (unlikely((__pyx_v_price == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 125, __pyx_L3_error) + __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 128, __pyx_L3_error) + __pyx_v_price = __pyx_PyFloat_AsDouble(values[6]); if (unlikely((__pyx_v_price == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 128, __pyx_L3_error) __pyx_v_currency = ((PyObject*)values[7]); - __pyx_v_sell = __Pyx_PyObject_IsTrue(values[8]); if (unlikely((__pyx_v_sell == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 126, __pyx_L3_error) + __pyx_v_sell = __Pyx_PyObject_IsTrue(values[8]); if (unlikely((__pyx_v_sell == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 129, __pyx_L3_error) __pyx_v_status = ((PyObject*)values[9]); - __pyx_v_final_quantity = __pyx_PyFloat_AsDouble(values[10]); if (unlikely((__pyx_v_final_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 126, __pyx_L3_error) - __pyx_v_id = __Pyx_PyInt_As_long(values[11]); if (unlikely((__pyx_v_id == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 126, __pyx_L3_error) - __pyx_v_made = __Pyx_PyInt_As_int(values[12]); if (unlikely((__pyx_v_made == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 127, __pyx_L3_error) - __pyx_v_status_round = __Pyx_PyInt_As_int(values[13]); if (unlikely((__pyx_v_status_round == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 127, __pyx_L3_error) + __pyx_v_final_quantity = __pyx_PyFloat_AsDouble(values[10]); if (unlikely((__pyx_v_final_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 129, __pyx_L3_error) + __pyx_v_id = __Pyx_PyInt_As_long(values[11]); if (unlikely((__pyx_v_id == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 129, __pyx_L3_error) + __pyx_v_made = __Pyx_PyInt_As_int(values[12]); if (unlikely((__pyx_v_made == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 130, __pyx_L3_error) + __pyx_v_status_round = __Pyx_PyInt_As_int(values[13]); if (unlikely((__pyx_v_status_round == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 130, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 124, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 14, 14, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 127, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Offer.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sender_group), (&PyString_Type), 1, "sender_group", 1))) __PYX_ERR(0, 124, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_receiver_group), (&PyString_Type), 1, "receiver_group", 1))) __PYX_ERR(0, 124, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_currency), (&PyString_Type), 1, "currency", 1))) __PYX_ERR(0, 125, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_status), (&PyString_Type), 1, "status", 1))) __PYX_ERR(0, 126, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sender_group), (&PyString_Type), 1, "sender_group", 1))) __PYX_ERR(0, 127, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_receiver_group), (&PyString_Type), 1, "receiver_group", 1))) __PYX_ERR(0, 127, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_currency), (&PyString_Type), 1, "currency", 1))) __PYX_ERR(0, 128, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_status), (&PyString_Type), 1, "status", 1))) __PYX_ERR(0, 129, __pyx_L1_error) __pyx_r = __pyx_pf_5trade_5Offer___cinit__(((struct __pyx_obj_5trade_Offer *)__pyx_v_self), __pyx_v_sender_group, __pyx_v_sender_id, __pyx_v_receiver_group, __pyx_v_receiver_id, __pyx_v_good, __pyx_v_quantity, __pyx_v_price, __pyx_v_currency, __pyx_v_sell, __pyx_v_status, __pyx_v_final_quantity, __pyx_v_id, __pyx_v_made, __pyx_v_status_round); /* function exit code */ @@ -1679,16 +1687,16 @@ static int __pyx_pf_5trade_5Offer___cinit__(struct __pyx_obj_5trade_Offer *__pyx PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "trade.pyx":128 + /* "trade.pyx":131 * bint sell, str status, double final_quantity, long id, * int made, int status_round): * self.sender = (sender_group, sender_id) # <<<<<<<<<<<<<< * self.sender_group = sender_group * self.sender_id = sender_id */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_sender_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_sender_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_sender_group); __Pyx_GIVEREF(__pyx_v_sender_group); @@ -1702,7 +1710,7 @@ static int __pyx_pf_5trade_5Offer___cinit__(struct __pyx_obj_5trade_Offer *__pyx __pyx_v_self->sender = __pyx_t_2; __pyx_t_2 = 0; - /* "trade.pyx":129 + /* "trade.pyx":132 * int made, int status_round): * self.sender = (sender_group, sender_id) * self.sender_group = sender_group # <<<<<<<<<<<<<< @@ -1715,7 +1723,7 @@ static int __pyx_pf_5trade_5Offer___cinit__(struct __pyx_obj_5trade_Offer *__pyx __Pyx_DECREF(__pyx_v_self->sender_group); __pyx_v_self->sender_group = __pyx_v_sender_group; - /* "trade.pyx":130 + /* "trade.pyx":133 * self.sender = (sender_group, sender_id) * self.sender_group = sender_group * self.sender_id = sender_id # <<<<<<<<<<<<<< @@ -1724,7 +1732,7 @@ static int __pyx_pf_5trade_5Offer___cinit__(struct __pyx_obj_5trade_Offer *__pyx */ __pyx_v_self->sender_id = __pyx_v_sender_id; - /* "trade.pyx":131 + /* "trade.pyx":134 * self.sender_group = sender_group * self.sender_id = sender_id * self.receiver_group = receiver_group # <<<<<<<<<<<<<< @@ -1737,7 +1745,7 @@ static int __pyx_pf_5trade_5Offer___cinit__(struct __pyx_obj_5trade_Offer *__pyx __Pyx_DECREF(__pyx_v_self->receiver_group); __pyx_v_self->receiver_group = __pyx_v_receiver_group; - /* "trade.pyx":132 + /* "trade.pyx":135 * self.sender_id = sender_id * self.receiver_group = receiver_group * self.receiver_id = receiver_id # <<<<<<<<<<<<<< @@ -1746,7 +1754,7 @@ static int __pyx_pf_5trade_5Offer___cinit__(struct __pyx_obj_5trade_Offer *__pyx */ __pyx_v_self->receiver_id = __pyx_v_receiver_id; - /* "trade.pyx":133 + /* "trade.pyx":136 * self.receiver_group = receiver_group * self.receiver_id = receiver_id * self.good = good # <<<<<<<<<<<<<< @@ -1759,7 +1767,7 @@ static int __pyx_pf_5trade_5Offer___cinit__(struct __pyx_obj_5trade_Offer *__pyx __Pyx_DECREF(__pyx_v_self->good); __pyx_v_self->good = __pyx_v_good; - /* "trade.pyx":134 + /* "trade.pyx":137 * self.receiver_id = receiver_id * self.good = good * self.currency = currency # <<<<<<<<<<<<<< @@ -1772,7 +1780,7 @@ static int __pyx_pf_5trade_5Offer___cinit__(struct __pyx_obj_5trade_Offer *__pyx __Pyx_DECREF(__pyx_v_self->currency); __pyx_v_self->currency = __pyx_v_currency; - /* "trade.pyx":135 + /* "trade.pyx":138 * self.good = good * self.currency = currency * self.quantity = quantity # <<<<<<<<<<<<<< @@ -1781,7 +1789,7 @@ static int __pyx_pf_5trade_5Offer___cinit__(struct __pyx_obj_5trade_Offer *__pyx */ __pyx_v_self->quantity = __pyx_v_quantity; - /* "trade.pyx":136 + /* "trade.pyx":139 * self.currency = currency * self.quantity = quantity * self.price = price # <<<<<<<<<<<<<< @@ -1790,7 +1798,7 @@ static int __pyx_pf_5trade_5Offer___cinit__(struct __pyx_obj_5trade_Offer *__pyx */ __pyx_v_self->price = __pyx_v_price; - /* "trade.pyx":137 + /* "trade.pyx":140 * self.quantity = quantity * self.price = price * self.sell = sell # <<<<<<<<<<<<<< @@ -1799,7 +1807,7 @@ static int __pyx_pf_5trade_5Offer___cinit__(struct __pyx_obj_5trade_Offer *__pyx */ __pyx_v_self->sell = __pyx_v_sell; - /* "trade.pyx":138 + /* "trade.pyx":141 * self.price = price * self.sell = sell * self.status = status # <<<<<<<<<<<<<< @@ -1812,7 +1820,7 @@ static int __pyx_pf_5trade_5Offer___cinit__(struct __pyx_obj_5trade_Offer *__pyx __Pyx_DECREF(__pyx_v_self->status); __pyx_v_self->status = __pyx_v_status; - /* "trade.pyx":139 + /* "trade.pyx":142 * self.sell = sell * self.status = status * self.final_quantity = final_quantity # <<<<<<<<<<<<<< @@ -1821,14 +1829,14 @@ static int __pyx_pf_5trade_5Offer___cinit__(struct __pyx_obj_5trade_Offer *__pyx */ __pyx_v_self->final_quantity = __pyx_v_final_quantity; - /* "trade.pyx":140 + /* "trade.pyx":143 * self.status = status * self.final_quantity = final_quantity * self.id = id # <<<<<<<<<<<<<< * self.made = made * self.status_round = status_round */ - __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __Pyx_GOTREF(__pyx_v_self->id); @@ -1836,7 +1844,7 @@ static int __pyx_pf_5trade_5Offer___cinit__(struct __pyx_obj_5trade_Offer *__pyx __pyx_v_self->id = __pyx_t_2; __pyx_t_2 = 0; - /* "trade.pyx":141 + /* "trade.pyx":144 * self.final_quantity = final_quantity * self.id = id * self.made = made # <<<<<<<<<<<<<< @@ -1845,7 +1853,7 @@ static int __pyx_pf_5trade_5Offer___cinit__(struct __pyx_obj_5trade_Offer *__pyx */ __pyx_v_self->made = __pyx_v_made; - /* "trade.pyx":142 + /* "trade.pyx":145 * self.id = id * self.made = made * self.status_round = status_round # <<<<<<<<<<<<<< @@ -1854,7 +1862,7 @@ static int __pyx_pf_5trade_5Offer___cinit__(struct __pyx_obj_5trade_Offer *__pyx */ __pyx_v_self->status_round = __pyx_v_status_round; - /* "trade.pyx":124 + /* "trade.pyx":127 * cdef readonly object sender * * def __cinit__(self, str sender_group, int sender_id, str receiver_group, # <<<<<<<<<<<<<< @@ -1875,7 +1883,7 @@ static int __pyx_pf_5trade_5Offer___cinit__(struct __pyx_obj_5trade_Offer *__pyx return __pyx_r; } -/* "trade.pyx":144 +/* "trade.pyx":147 * self.status_round = status_round * * def __reduce__(self): # <<<<<<<<<<<<<< @@ -1911,7 +1919,7 @@ static PyObject *__pyx_pf_5trade_5Offer_2__reduce__(struct __pyx_obj_5trade_Offe PyObject *__pyx_t_10 = NULL; __Pyx_RefNannySetupContext("__reduce__", 0); - /* "trade.pyx":145 + /* "trade.pyx":148 * * def __reduce__(self): * return (rebuild_offer, (self.sender_group, self.sender_id, self.receiver_group, # <<<<<<<<<<<<<< @@ -1919,57 +1927,57 @@ static PyObject *__pyx_pf_5trade_5Offer_2__reduce__(struct __pyx_obj_5trade_Offe * self.sell, self.status, self.final_quantity, self.id, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_rebuild_offer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_rebuild_offer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->sender_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 145, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->sender_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - /* "trade.pyx":146 + /* "trade.pyx":149 * def __reduce__(self): * return (rebuild_offer, (self.sender_group, self.sender_id, self.receiver_group, * self.receiver_id, self.good, self.quantity, self.price, self.currency, # <<<<<<<<<<<<<< * self.sell, self.status, self.final_quantity, self.id, * self.made, self.status_round)) */ - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_self->receiver_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 146, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_self->receiver_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->quantity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 146, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->quantity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyFloat_FromDouble(__pyx_v_self->price); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 146, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_self->price); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - /* "trade.pyx":147 + /* "trade.pyx":150 * return (rebuild_offer, (self.sender_group, self.sender_id, self.receiver_group, * self.receiver_id, self.good, self.quantity, self.price, self.currency, * self.sell, self.status, self.final_quantity, self.id, # <<<<<<<<<<<<<< * self.made, self.status_round)) * */ - __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_v_self->sell); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 147, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_v_self->sell); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyFloat_FromDouble(__pyx_v_self->final_quantity); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 147, __pyx_L1_error) + __pyx_t_7 = PyFloat_FromDouble(__pyx_v_self->final_quantity); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - /* "trade.pyx":148 + /* "trade.pyx":151 * self.receiver_id, self.good, self.quantity, self.price, self.currency, * self.sell, self.status, self.final_quantity, self.id, * self.made, self.status_round)) # <<<<<<<<<<<<<< * * def __repr__(self): */ - __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_self->made); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 148, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_self->made); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_self->status_round); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 148, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_self->status_round); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - /* "trade.pyx":145 + /* "trade.pyx":148 * * def __reduce__(self): * return (rebuild_offer, (self.sender_group, self.sender_id, self.receiver_group, # <<<<<<<<<<<<<< * self.receiver_id, self.good, self.quantity, self.price, self.currency, * self.sell, self.status, self.final_quantity, self.id, */ - __pyx_t_10 = PyTuple_New(14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 145, __pyx_L1_error) + __pyx_t_10 = PyTuple_New(14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_INCREF(__pyx_v_self->sender_group); __Pyx_GIVEREF(__pyx_v_self->sender_group); @@ -2013,7 +2021,7 @@ static PyObject *__pyx_pf_5trade_5Offer_2__reduce__(struct __pyx_obj_5trade_Offe __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; - __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 145, __pyx_L1_error) + __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1); @@ -2025,7 +2033,7 @@ static PyObject *__pyx_pf_5trade_5Offer_2__reduce__(struct __pyx_obj_5trade_Offe __pyx_t_9 = 0; goto __pyx_L0; - /* "trade.pyx":144 + /* "trade.pyx":147 * self.status_round = status_round * * def __reduce__(self): # <<<<<<<<<<<<<< @@ -2053,7 +2061,7 @@ static PyObject *__pyx_pf_5trade_5Offer_2__reduce__(struct __pyx_obj_5trade_Offe return __pyx_r; } -/* "trade.pyx":150 +/* "trade.pyx":153 * self.made, self.status_round)) * * def __repr__(self): # <<<<<<<<<<<<<< @@ -2088,7 +2096,7 @@ static PyObject *__pyx_pf_5trade_5Offer_4__repr__(struct __pyx_obj_5trade_Offer PyObject *__pyx_t_9 = NULL; __Pyx_RefNannySetupContext("__repr__", 0); - /* "trade.pyx":151 + /* "trade.pyx":154 * * def __repr__(self): * return """<{sender: %s, %i, receiver_group: %s, # <<<<<<<<<<<<<< @@ -2097,62 +2105,62 @@ static PyObject *__pyx_pf_5trade_5Offer_4__repr__(struct __pyx_obj_5trade_Offer */ __Pyx_XDECREF(__pyx_r); - /* "trade.pyx":156 + /* "trade.pyx":159 * made: %i, status_round: %i }>""" % ( * * self.sender_group, self.sender_id, self.receiver_group, # <<<<<<<<<<<<<< * self.receiver_id, self.good, self.quantity, self.price, * self.sell, self.status, self.final_quantity, self.id, */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->sender_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->sender_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - /* "trade.pyx":157 + /* "trade.pyx":160 * * self.sender_group, self.sender_id, self.receiver_group, * self.receiver_id, self.good, self.quantity, self.price, # <<<<<<<<<<<<<< * self.sell, self.status, self.final_quantity, self.id, * self.made, self.status_round) */ - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->receiver_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->receiver_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->price); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->price); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - /* "trade.pyx":158 + /* "trade.pyx":161 * self.sender_group, self.sender_id, self.receiver_group, * self.receiver_id, self.good, self.quantity, self.price, * self.sell, self.status, self.final_quantity, self.id, # <<<<<<<<<<<<<< * self.made, self.status_round) * */ - __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_self->sell); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 158, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_self->sell); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_self->final_quantity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 158, __pyx_L1_error) + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_self->final_quantity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - /* "trade.pyx":159 + /* "trade.pyx":162 * self.receiver_id, self.good, self.quantity, self.price, * self.sell, self.status, self.final_quantity, self.id, * self.made, self.status_round) # <<<<<<<<<<<<<< * * def rebuild_offer(str sender_group, int sender_id, str receiver_group, */ - __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_self->made); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 159, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_self->made); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_self->status_round); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 159, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_self->status_round); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - /* "trade.pyx":156 + /* "trade.pyx":159 * made: %i, status_round: %i }>""" % ( * * self.sender_group, self.sender_id, self.receiver_group, # <<<<<<<<<<<<<< * self.receiver_id, self.good, self.quantity, self.price, * self.sell, self.status, self.final_quantity, self.id, */ - __pyx_t_9 = PyTuple_New(13); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_t_9 = PyTuple_New(13); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_v_self->sender_group); __Pyx_GIVEREF(__pyx_v_self->sender_group); @@ -2194,21 +2202,21 @@ static PyObject *__pyx_pf_5trade_5Offer_4__repr__(struct __pyx_obj_5trade_Offer __pyx_t_7 = 0; __pyx_t_8 = 0; - /* "trade.pyx":154 + /* "trade.pyx":157 * receiver_id: %i, good: %s, quantity: %f, price: %f, * sell: %r, status: %s, final_quantity: % f, id: %i, * made: %i, status_round: %i }>""" % ( # <<<<<<<<<<<<<< * * self.sender_group, self.sender_id, self.receiver_group, */ - __pyx_t_8 = __Pyx_PyString_Format(__pyx_kp_s_sender_s_i_receiver_group_s_rec, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 154, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyString_Format(__pyx_kp_s_sender_s_i_receiver_group_s_rec, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 157, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_r = __pyx_t_8; __pyx_t_8 = 0; goto __pyx_L0; - /* "trade.pyx":150 + /* "trade.pyx":153 * self.made, self.status_round)) * * def __repr__(self): # <<<<<<<<<<<<<< @@ -2235,7 +2243,7 @@ static PyObject *__pyx_pf_5trade_5Offer_4__repr__(struct __pyx_obj_5trade_Offer return __pyx_r; } -/* "trade.pyx":108 +/* "trade.pyx":111 * a unique identifier * """ * cdef readonly str sender_group # <<<<<<<<<<<<<< @@ -2272,7 +2280,7 @@ static PyObject *__pyx_pf_5trade_5Offer_12sender_group___get__(struct __pyx_obj_ return __pyx_r; } -/* "trade.pyx":109 +/* "trade.pyx":112 * """ * cdef readonly str sender_group * cdef readonly int sender_id # <<<<<<<<<<<<<< @@ -2299,7 +2307,7 @@ static PyObject *__pyx_pf_5trade_5Offer_9sender_id___get__(struct __pyx_obj_5tra PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->sender_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->sender_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2316,7 +2324,7 @@ static PyObject *__pyx_pf_5trade_5Offer_9sender_id___get__(struct __pyx_obj_5tra return __pyx_r; } -/* "trade.pyx":110 +/* "trade.pyx":113 * cdef readonly str sender_group * cdef readonly int sender_id * cdef readonly str receiver_group # <<<<<<<<<<<<<< @@ -2353,7 +2361,7 @@ static PyObject *__pyx_pf_5trade_5Offer_14receiver_group___get__(struct __pyx_ob return __pyx_r; } -/* "trade.pyx":111 +/* "trade.pyx":114 * cdef readonly int sender_id * cdef readonly str receiver_group * cdef readonly int receiver_id # <<<<<<<<<<<<<< @@ -2380,7 +2388,7 @@ static PyObject *__pyx_pf_5trade_5Offer_11receiver_id___get__(struct __pyx_obj_5 PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->receiver_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 111, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->receiver_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2397,7 +2405,7 @@ static PyObject *__pyx_pf_5trade_5Offer_11receiver_id___get__(struct __pyx_obj_5 return __pyx_r; } -/* "trade.pyx":112 +/* "trade.pyx":115 * cdef readonly str receiver_group * cdef readonly int receiver_id * cdef readonly object good # <<<<<<<<<<<<<< @@ -2434,7 +2442,7 @@ static PyObject *__pyx_pf_5trade_5Offer_4good___get__(struct __pyx_obj_5trade_Of return __pyx_r; } -/* "trade.pyx":113 +/* "trade.pyx":116 * cdef readonly int receiver_id * cdef readonly object good * cdef readonly str currency # <<<<<<<<<<<<<< @@ -2471,7 +2479,7 @@ static PyObject *__pyx_pf_5trade_5Offer_8currency___get__(struct __pyx_obj_5trad return __pyx_r; } -/* "trade.pyx":114 +/* "trade.pyx":117 * cdef readonly object good * cdef readonly str currency * cdef readonly double quantity # <<<<<<<<<<<<<< @@ -2498,7 +2506,7 @@ static PyObject *__pyx_pf_5trade_5Offer_8quantity___get__(struct __pyx_obj_5trad PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->quantity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->quantity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2515,7 +2523,7 @@ static PyObject *__pyx_pf_5trade_5Offer_8quantity___get__(struct __pyx_obj_5trad return __pyx_r; } -/* "trade.pyx":115 +/* "trade.pyx":118 * cdef readonly str currency * cdef readonly double quantity * cdef readonly double price # <<<<<<<<<<<<<< @@ -2542,7 +2550,7 @@ static PyObject *__pyx_pf_5trade_5Offer_5price___get__(struct __pyx_obj_5trade_O PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 115, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 118, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2559,7 +2567,7 @@ static PyObject *__pyx_pf_5trade_5Offer_5price___get__(struct __pyx_obj_5trade_O return __pyx_r; } -/* "trade.pyx":116 +/* "trade.pyx":119 * cdef readonly double quantity * cdef readonly double price * cdef readonly bint sell # <<<<<<<<<<<<<< @@ -2586,7 +2594,7 @@ static PyObject *__pyx_pf_5trade_5Offer_4sell___get__(struct __pyx_obj_5trade_Of PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->sell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 116, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->sell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2603,7 +2611,7 @@ static PyObject *__pyx_pf_5trade_5Offer_4sell___get__(struct __pyx_obj_5trade_Of return __pyx_r; } -/* "trade.pyx":117 +/* "trade.pyx":120 * cdef readonly double price * cdef readonly bint sell * cdef public str status # <<<<<<<<<<<<<< @@ -2658,7 +2666,7 @@ static int __pyx_pf_5trade_5Offer_6status_2__set__(struct __pyx_obj_5trade_Offer __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__set__", 0); - if (!(likely(PyString_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 117, __pyx_L1_error) + if (!(likely(PyString_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 120, __pyx_L1_error) __pyx_t_1 = __pyx_v_value; __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -2708,7 +2716,7 @@ static int __pyx_pf_5trade_5Offer_6status_4__del__(struct __pyx_obj_5trade_Offer return __pyx_r; } -/* "trade.pyx":118 +/* "trade.pyx":121 * cdef readonly bint sell * cdef public str status * cdef public double final_quantity # <<<<<<<<<<<<<< @@ -2735,7 +2743,7 @@ static PyObject *__pyx_pf_5trade_5Offer_14final_quantity___get__(struct __pyx_ob PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->final_quantity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 118, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->final_quantity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2770,7 +2778,7 @@ static int __pyx_pf_5trade_5Offer_14final_quantity_2__set__(struct __pyx_obj_5tr __Pyx_RefNannyDeclarations double __pyx_t_1; __Pyx_RefNannySetupContext("__set__", 0); - __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 118, __pyx_L1_error) + __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 121, __pyx_L1_error) __pyx_v_self->final_quantity = __pyx_t_1; /* function exit code */ @@ -2784,7 +2792,7 @@ static int __pyx_pf_5trade_5Offer_14final_quantity_2__set__(struct __pyx_obj_5tr return __pyx_r; } -/* "trade.pyx":119 +/* "trade.pyx":122 * cdef public str status * cdef public double final_quantity * cdef readonly object id # <<<<<<<<<<<<<< @@ -2821,7 +2829,7 @@ static PyObject *__pyx_pf_5trade_5Offer_2id___get__(struct __pyx_obj_5trade_Offe return __pyx_r; } -/* "trade.pyx":120 +/* "trade.pyx":123 * cdef public double final_quantity * cdef readonly object id * cdef readonly int made # <<<<<<<<<<<<<< @@ -2848,7 +2856,7 @@ static PyObject *__pyx_pf_5trade_5Offer_4made___get__(struct __pyx_obj_5trade_Of PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->made); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 120, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->made); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2865,7 +2873,7 @@ static PyObject *__pyx_pf_5trade_5Offer_4made___get__(struct __pyx_obj_5trade_Of return __pyx_r; } -/* "trade.pyx":121 +/* "trade.pyx":124 * cdef readonly object id * cdef readonly int made * cdef public int status_round # <<<<<<<<<<<<<< @@ -2892,7 +2900,7 @@ static PyObject *__pyx_pf_5trade_5Offer_12status_round___get__(struct __pyx_obj_ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->status_round); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->status_round); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -2927,7 +2935,7 @@ static int __pyx_pf_5trade_5Offer_12status_round_2__set__(struct __pyx_obj_5trad __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__set__", 0); - __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 121, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 124, __pyx_L1_error) __pyx_v_self->status_round = __pyx_t_1; /* function exit code */ @@ -2941,7 +2949,7 @@ static int __pyx_pf_5trade_5Offer_12status_round_2__set__(struct __pyx_obj_5trad return __pyx_r; } -/* "trade.pyx":122 +/* "trade.pyx":125 * cdef readonly int made * cdef public int status_round * cdef readonly object sender # <<<<<<<<<<<<<< @@ -2978,7 +2986,7 @@ static PyObject *__pyx_pf_5trade_5Offer_6sender___get__(struct __pyx_obj_5trade_ return __pyx_r; } -/* "trade.pyx":161 +/* "trade.pyx":164 * self.made, self.status_round) * * def rebuild_offer(str sender_group, int sender_id, str receiver_group, # <<<<<<<<<<<<<< @@ -3039,71 +3047,71 @@ static PyObject *__pyx_pw_5trade_3rebuild_offer(PyObject *__pyx_self, PyObject * case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_sender_id)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 1); __PYX_ERR(0, 161, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 1); __PYX_ERR(0, 164, __pyx_L3_error) } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_receiver_group)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 2); __PYX_ERR(0, 161, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 2); __PYX_ERR(0, 164, __pyx_L3_error) } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_receiver_id)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 3); __PYX_ERR(0, 161, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 3); __PYX_ERR(0, 164, __pyx_L3_error) } case 4: if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_good)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 4); __PYX_ERR(0, 161, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 4); __PYX_ERR(0, 164, __pyx_L3_error) } case 5: if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_quantity)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 5); __PYX_ERR(0, 161, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 5); __PYX_ERR(0, 164, __pyx_L3_error) } case 6: if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_price)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 6); __PYX_ERR(0, 161, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 6); __PYX_ERR(0, 164, __pyx_L3_error) } case 7: if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_currency)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 7); __PYX_ERR(0, 161, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 7); __PYX_ERR(0, 164, __pyx_L3_error) } case 8: if (likely((values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_sell)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 8); __PYX_ERR(0, 161, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 8); __PYX_ERR(0, 164, __pyx_L3_error) } case 9: if (likely((values[9] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_status)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 9); __PYX_ERR(0, 161, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 9); __PYX_ERR(0, 164, __pyx_L3_error) } case 10: if (likely((values[10] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_final_quantity)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 10); __PYX_ERR(0, 161, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 10); __PYX_ERR(0, 164, __pyx_L3_error) } case 11: if (likely((values[11] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_id)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 11); __PYX_ERR(0, 161, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 11); __PYX_ERR(0, 164, __pyx_L3_error) } case 12: if (likely((values[12] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_made)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 12); __PYX_ERR(0, 161, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 12); __PYX_ERR(0, 164, __pyx_L3_error) } case 13: if (likely((values[13] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_status_round)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 13); __PYX_ERR(0, 161, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, 13); __PYX_ERR(0, 164, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rebuild_offer") < 0)) __PYX_ERR(0, 161, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rebuild_offer") < 0)) __PYX_ERR(0, 164, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 14) { goto __pyx_L5_argtuple_error; @@ -3124,32 +3132,32 @@ static PyObject *__pyx_pw_5trade_3rebuild_offer(PyObject *__pyx_self, PyObject * values[13] = PyTuple_GET_ITEM(__pyx_args, 13); } __pyx_v_sender_group = ((PyObject*)values[0]); - __pyx_v_sender_id = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_sender_id == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 161, __pyx_L3_error) + __pyx_v_sender_id = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_sender_id == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L3_error) __pyx_v_receiver_group = ((PyObject*)values[2]); - __pyx_v_receiver_id = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_receiver_id == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 162, __pyx_L3_error) + __pyx_v_receiver_id = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_receiver_id == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 165, __pyx_L3_error) __pyx_v_good = values[4]; - __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 162, __pyx_L3_error) - __pyx_v_price = __pyx_PyFloat_AsDouble(values[6]); if (unlikely((__pyx_v_price == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 162, __pyx_L3_error) + __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 165, __pyx_L3_error) + __pyx_v_price = __pyx_PyFloat_AsDouble(values[6]); if (unlikely((__pyx_v_price == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 165, __pyx_L3_error) __pyx_v_currency = ((PyObject*)values[7]); - __pyx_v_sell = __Pyx_PyObject_IsTrue(values[8]); if (unlikely((__pyx_v_sell == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 163, __pyx_L3_error) + __pyx_v_sell = __Pyx_PyObject_IsTrue(values[8]); if (unlikely((__pyx_v_sell == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 166, __pyx_L3_error) __pyx_v_status = ((PyObject*)values[9]); - __pyx_v_final_quantity = __pyx_PyFloat_AsDouble(values[10]); if (unlikely((__pyx_v_final_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 163, __pyx_L3_error) - __pyx_v_id = __Pyx_PyInt_As_long(values[11]); if (unlikely((__pyx_v_id == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L3_error) - __pyx_v_made = __Pyx_PyInt_As_int(values[12]); if (unlikely((__pyx_v_made == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L3_error) - __pyx_v_status_round = __Pyx_PyInt_As_int(values[13]); if (unlikely((__pyx_v_status_round == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L3_error) + __pyx_v_final_quantity = __pyx_PyFloat_AsDouble(values[10]); if (unlikely((__pyx_v_final_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 166, __pyx_L3_error) + __pyx_v_id = __Pyx_PyInt_As_long(values[11]); if (unlikely((__pyx_v_id == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 167, __pyx_L3_error) + __pyx_v_made = __Pyx_PyInt_As_int(values[12]); if (unlikely((__pyx_v_made == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 167, __pyx_L3_error) + __pyx_v_status_round = __Pyx_PyInt_As_int(values[13]); if (unlikely((__pyx_v_status_round == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 167, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 161, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("rebuild_offer", 1, 14, 14, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 164, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.rebuild_offer", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sender_group), (&PyString_Type), 1, "sender_group", 1))) __PYX_ERR(0, 161, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_receiver_group), (&PyString_Type), 1, "receiver_group", 1))) __PYX_ERR(0, 161, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_currency), (&PyString_Type), 1, "currency", 1))) __PYX_ERR(0, 163, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_status), (&PyString_Type), 1, "status", 1))) __PYX_ERR(0, 163, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sender_group), (&PyString_Type), 1, "sender_group", 1))) __PYX_ERR(0, 164, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_receiver_group), (&PyString_Type), 1, "receiver_group", 1))) __PYX_ERR(0, 164, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_currency), (&PyString_Type), 1, "currency", 1))) __PYX_ERR(0, 166, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_status), (&PyString_Type), 1, "status", 1))) __PYX_ERR(0, 166, __pyx_L1_error) __pyx_r = __pyx_pf_5trade_2rebuild_offer(__pyx_self, __pyx_v_sender_group, __pyx_v_sender_id, __pyx_v_receiver_group, __pyx_v_receiver_id, __pyx_v_good, __pyx_v_quantity, __pyx_v_price, __pyx_v_currency, __pyx_v_sell, __pyx_v_status, __pyx_v_final_quantity, __pyx_v_id, __pyx_v_made, __pyx_v_status_round); /* function exit code */ @@ -3176,7 +3184,7 @@ static PyObject *__pyx_pf_5trade_2rebuild_offer(CYTHON_UNUSED PyObject *__pyx_se PyObject *__pyx_t_10 = NULL; __Pyx_RefNannySetupContext("rebuild_offer", 0); - /* "trade.pyx":165 + /* "trade.pyx":168 * str currency, bint sell, str status, double final_quantity, * long id, int made, int status_round): * return Offer(sender_group, sender_id, receiver_group, # <<<<<<<<<<<<<< @@ -3184,57 +3192,57 @@ static PyObject *__pyx_pf_5trade_2rebuild_offer(CYTHON_UNUSED PyObject *__pyx_se * sell, status, final_quantity, id, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_sender_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_sender_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - /* "trade.pyx":166 + /* "trade.pyx":169 * long id, int made, int status_round): * return Offer(sender_group, sender_id, receiver_group, * receiver_id, good, quantity, price, currency, # <<<<<<<<<<<<<< * sell, status, final_quantity, id, * made, status_round) */ - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_receiver_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_receiver_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 169, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyFloat_FromDouble(__pyx_v_price); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_price); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 169, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - /* "trade.pyx":167 + /* "trade.pyx":170 * return Offer(sender_group, sender_id, receiver_group, * receiver_id, good, quantity, price, currency, * sell, status, final_quantity, id, # <<<<<<<<<<<<<< * made, status_round) * */ - __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_sell); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 167, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_sell); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_final_quantity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 167, __pyx_L1_error) + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_final_quantity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = __Pyx_PyInt_From_long(__pyx_v_id); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 167, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyInt_From_long(__pyx_v_id); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - /* "trade.pyx":168 + /* "trade.pyx":171 * receiver_id, good, quantity, price, currency, * sell, status, final_quantity, id, * made, status_round) # <<<<<<<<<<<<<< * * cdef class Trade: */ - __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_made); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 168, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_made); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_status_round); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 168, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_status_round); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - /* "trade.pyx":165 + /* "trade.pyx":168 * str currency, bint sell, str status, double final_quantity, * long id, int made, int status_round): * return Offer(sender_group, sender_id, receiver_group, # <<<<<<<<<<<<<< * receiver_id, good, quantity, price, currency, * sell, status, final_quantity, id, */ - __pyx_t_10 = PyTuple_New(14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 165, __pyx_L1_error) + __pyx_t_10 = PyTuple_New(14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_INCREF(__pyx_v_sender_group); __Pyx_GIVEREF(__pyx_v_sender_group); @@ -3278,14 +3286,14 @@ static PyObject *__pyx_pf_5trade_2rebuild_offer(CYTHON_UNUSED PyObject *__pyx_se __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; - __pyx_t_9 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5trade_Offer), __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 165, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5trade_Offer), __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_r = __pyx_t_9; __pyx_t_9 = 0; goto __pyx_L0; - /* "trade.pyx":161 + /* "trade.pyx":164 * self.made, self.status_round) * * def rebuild_offer(str sender_group, int sender_id, str receiver_group, # <<<<<<<<<<<<<< @@ -3313,7 +3321,7 @@ static PyObject *__pyx_pf_5trade_2rebuild_offer(CYTHON_UNUSED PyObject *__pyx_se return __pyx_r; } -/* "trade.pyx":239 +/* "trade.pyx":242 * If we did not implement a barter class, but one can use this class as a barter class, * """ * def get_buy_offers_all(self, descending=False, sorted=True): # <<<<<<<<<<<<<< @@ -3357,7 +3365,7 @@ static PyObject *__pyx_pw_5trade_5Trade_1get_buy_offers_all(PyObject *__pyx_v_se } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_buy_offers_all") < 0)) __PYX_ERR(0, 239, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_buy_offers_all") < 0)) __PYX_ERR(0, 242, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -3372,7 +3380,7 @@ static PyObject *__pyx_pw_5trade_5Trade_1get_buy_offers_all(PyObject *__pyx_v_se } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("get_buy_offers_all", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 239, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("get_buy_offers_all", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 242, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade.get_buy_offers_all", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -3399,16 +3407,16 @@ static PyObject *__pyx_pf_5trade_5Trade_get_buy_offers_all(struct __pyx_obj_5tra PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("get_buy_offers_all", 0); - /* "trade.pyx":240 + /* "trade.pyx":243 * """ * def get_buy_offers_all(self, descending=False, sorted=True): * goods = list(self._open_offers_buy.keys()) # <<<<<<<<<<<<<< * return {good: self.get_offers(good, descending, sorted) for good in goods} * */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 240, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_keys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 240, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_keys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; @@ -3422,20 +3430,20 @@ static PyObject *__pyx_pf_5trade_5Trade_get_buy_offers_all(struct __pyx_obj_5tra } } if (__pyx_t_2) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 240, __pyx_L1_error) + __pyx_t_3 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_goods = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; - /* "trade.pyx":241 + /* "trade.pyx":244 * def get_buy_offers_all(self, descending=False, sorted=True): * goods = list(self._open_offers_buy.keys()) * return {good: self.get_offers(good, descending, sorted) for good in goods} # <<<<<<<<<<<<<< @@ -3445,20 +3453,20 @@ static PyObject *__pyx_pf_5trade_5Trade_get_buy_offers_all(struct __pyx_obj_5tra __Pyx_XDECREF(__pyx_r); { /* enter inner scope */ PyObject *__pyx_7genexpr__pyx_v_good = NULL; - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 241, __pyx_L5_error) + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 244, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __pyx_v_goods; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0; for (;;) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 241, __pyx_L5_error) + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 244, __pyx_L5_error) #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 241, __pyx_L5_error) + __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 244, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); #endif __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_good, __pyx_t_2); __pyx_t_2 = 0; - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_offers); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 241, __pyx_L5_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_offers); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 244, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; @@ -3475,7 +3483,7 @@ static PyObject *__pyx_pf_5trade_5Trade_get_buy_offers_all(struct __pyx_obj_5tra #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_7genexpr__pyx_v_good, __pyx_v_descending, __pyx_v_sorted}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 241, __pyx_L5_error) + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 244, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_2); } else @@ -3483,13 +3491,13 @@ static PyObject *__pyx_pf_5trade_5Trade_get_buy_offers_all(struct __pyx_obj_5tra #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_7genexpr__pyx_v_good, __pyx_v_descending, __pyx_v_sorted}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 241, __pyx_L5_error) + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 244, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif { - __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 241, __pyx_L5_error) + __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 244, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; @@ -3503,12 +3511,12 @@ static PyObject *__pyx_pf_5trade_5Trade_get_buy_offers_all(struct __pyx_obj_5tra __Pyx_INCREF(__pyx_v_sorted); __Pyx_GIVEREF(__pyx_v_sorted); PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_v_sorted); - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 241, __pyx_L5_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 244, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(PyDict_SetItem(__pyx_t_3, (PyObject*)__pyx_7genexpr__pyx_v_good, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 241, __pyx_L5_error) + if (unlikely(PyDict_SetItem(__pyx_t_3, (PyObject*)__pyx_7genexpr__pyx_v_good, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 244, __pyx_L5_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -3523,7 +3531,7 @@ static PyObject *__pyx_pf_5trade_5Trade_get_buy_offers_all(struct __pyx_obj_5tra __pyx_t_3 = 0; goto __pyx_L0; - /* "trade.pyx":239 + /* "trade.pyx":242 * If we did not implement a barter class, but one can use this class as a barter class, * """ * def get_buy_offers_all(self, descending=False, sorted=True): # <<<<<<<<<<<<<< @@ -3548,7 +3556,7 @@ static PyObject *__pyx_pf_5trade_5Trade_get_buy_offers_all(struct __pyx_obj_5tra return __pyx_r; } -/* "trade.pyx":243 +/* "trade.pyx":246 * return {good: self.get_offers(good, descending, sorted) for good in goods} * * def get_sell_offers_all(self, descending=False, sorted=True): # <<<<<<<<<<<<<< @@ -3592,7 +3600,7 @@ static PyObject *__pyx_pw_5trade_5Trade_3get_sell_offers_all(PyObject *__pyx_v_s } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_sell_offers_all") < 0)) __PYX_ERR(0, 243, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_sell_offers_all") < 0)) __PYX_ERR(0, 246, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -3607,7 +3615,7 @@ static PyObject *__pyx_pw_5trade_5Trade_3get_sell_offers_all(PyObject *__pyx_v_s } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("get_sell_offers_all", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 243, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("get_sell_offers_all", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 246, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade.get_sell_offers_all", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -3634,16 +3642,16 @@ static PyObject *__pyx_pf_5trade_5Trade_2get_sell_offers_all(struct __pyx_obj_5t PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("get_sell_offers_all", 0); - /* "trade.pyx":244 + /* "trade.pyx":247 * * def get_sell_offers_all(self, descending=False, sorted=True): * goods = list(self._open_offers_sell.keys()) # <<<<<<<<<<<<<< * return {good: self.get_offers(good, descending, sorted) for good in goods} * */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 244, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 247, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_keys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 244, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_keys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 247, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; @@ -3657,20 +3665,20 @@ static PyObject *__pyx_pf_5trade_5Trade_2get_sell_offers_all(struct __pyx_obj_5t } } if (__pyx_t_2) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 244, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 247, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 244, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 247, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 244, __pyx_L1_error) + __pyx_t_3 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 247, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_goods = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; - /* "trade.pyx":245 + /* "trade.pyx":248 * def get_sell_offers_all(self, descending=False, sorted=True): * goods = list(self._open_offers_sell.keys()) * return {good: self.get_offers(good, descending, sorted) for good in goods} # <<<<<<<<<<<<<< @@ -3680,20 +3688,20 @@ static PyObject *__pyx_pf_5trade_5Trade_2get_sell_offers_all(struct __pyx_obj_5t __Pyx_XDECREF(__pyx_r); { /* enter inner scope */ PyObject *__pyx_8genexpr1__pyx_v_good = NULL; - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 245, __pyx_L5_error) + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 248, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __pyx_v_goods; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0; for (;;) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 245, __pyx_L5_error) + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 248, __pyx_L5_error) #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 245, __pyx_L5_error) + __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 248, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); #endif __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_good, __pyx_t_2); __pyx_t_2 = 0; - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_offers); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 245, __pyx_L5_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_offers); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 248, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; @@ -3710,7 +3718,7 @@ static PyObject *__pyx_pf_5trade_5Trade_2get_sell_offers_all(struct __pyx_obj_5t #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_8genexpr1__pyx_v_good, __pyx_v_descending, __pyx_v_sorted}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 245, __pyx_L5_error) + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 248, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_2); } else @@ -3718,13 +3726,13 @@ static PyObject *__pyx_pf_5trade_5Trade_2get_sell_offers_all(struct __pyx_obj_5t #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_8genexpr1__pyx_v_good, __pyx_v_descending, __pyx_v_sorted}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 245, __pyx_L5_error) + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 248, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif { - __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 245, __pyx_L5_error) + __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 248, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; @@ -3738,12 +3746,12 @@ static PyObject *__pyx_pf_5trade_5Trade_2get_sell_offers_all(struct __pyx_obj_5t __Pyx_INCREF(__pyx_v_sorted); __Pyx_GIVEREF(__pyx_v_sorted); PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_v_sorted); - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 245, __pyx_L5_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 248, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(PyDict_SetItem(__pyx_t_3, (PyObject*)__pyx_8genexpr1__pyx_v_good, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 245, __pyx_L5_error) + if (unlikely(PyDict_SetItem(__pyx_t_3, (PyObject*)__pyx_8genexpr1__pyx_v_good, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 248, __pyx_L5_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -3758,7 +3766,7 @@ static PyObject *__pyx_pf_5trade_5Trade_2get_sell_offers_all(struct __pyx_obj_5t __pyx_t_3 = 0; goto __pyx_L0; - /* "trade.pyx":243 + /* "trade.pyx":246 * return {good: self.get_offers(good, descending, sorted) for good in goods} * * def get_sell_offers_all(self, descending=False, sorted=True): # <<<<<<<<<<<<<< @@ -3783,7 +3791,7 @@ static PyObject *__pyx_pf_5trade_5Trade_2get_sell_offers_all(struct __pyx_obj_5t return __pyx_r; } -/* "trade.pyx":247 +/* "trade.pyx":250 * return {good: self.get_offers(good, descending, sorted) for good in goods} * * def get_offers_all(self, descending=False, sorted=True): # <<<<<<<<<<<<<< @@ -3828,7 +3836,7 @@ static PyObject *__pyx_pw_5trade_5Trade_5get_offers_all(PyObject *__pyx_v_self, } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_offers_all") < 0)) __PYX_ERR(0, 247, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_offers_all") < 0)) __PYX_ERR(0, 250, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -3843,7 +3851,7 @@ static PyObject *__pyx_pw_5trade_5Trade_5get_offers_all(PyObject *__pyx_v_self, } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("get_offers_all", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 247, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("get_offers_all", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 250, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade.get_offers_all", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -3870,16 +3878,16 @@ static PyObject *__pyx_pf_5trade_5Trade_4get_offers_all(struct __pyx_obj_5trade_ PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("get_offers_all", 0); - /* "trade.pyx":281 + /* "trade.pyx":284 * print(offer.price, offer.sender_group, offer.sender_id) * """ * goods = list(self._open_offers_sell.keys() + self._open_offers_buy.keys()) # <<<<<<<<<<<<<< * return {good: self.get_offers(good, descending, sorted) for good in goods} * */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 281, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_keys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 281, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_keys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; @@ -3893,16 +3901,16 @@ static PyObject *__pyx_pf_5trade_5Trade_4get_offers_all(struct __pyx_obj_5trade_ } } if (__pyx_t_2) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 284, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 281, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_keys); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 281, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_keys); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; @@ -3916,24 +3924,24 @@ static PyObject *__pyx_pf_5trade_5Trade_4get_offers_all(struct __pyx_obj_5trade_ } } if (__pyx_t_2) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 281, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { - __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 281, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 281, __pyx_L1_error) + __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PySequence_List(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 281, __pyx_L1_error) + __pyx_t_3 = PySequence_List(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_goods = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; - /* "trade.pyx":282 + /* "trade.pyx":285 * """ * goods = list(self._open_offers_sell.keys() + self._open_offers_buy.keys()) * return {good: self.get_offers(good, descending, sorted) for good in goods} # <<<<<<<<<<<<<< @@ -3943,20 +3951,20 @@ static PyObject *__pyx_pf_5trade_5Trade_4get_offers_all(struct __pyx_obj_5trade_ __Pyx_XDECREF(__pyx_r); { /* enter inner scope */ PyObject *__pyx_8genexpr2__pyx_v_good = NULL; - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 282, __pyx_L5_error) + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 285, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __pyx_v_goods; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0; for (;;) { if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 282, __pyx_L5_error) + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 285, __pyx_L5_error) #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 282, __pyx_L5_error) + __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_XDECREF_SET(__pyx_8genexpr2__pyx_v_good, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_offers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 282, __pyx_L5_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_offers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = NULL; __pyx_t_7 = 0; @@ -3973,7 +3981,7 @@ static PyObject *__pyx_pf_5trade_5Trade_4get_offers_all(struct __pyx_obj_5trade_ #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_8genexpr2__pyx_v_good, __pyx_v_descending, __pyx_v_sorted}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 282, __pyx_L5_error) + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); } else @@ -3981,13 +3989,13 @@ static PyObject *__pyx_pf_5trade_5Trade_4get_offers_all(struct __pyx_obj_5trade_ #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_8genexpr2__pyx_v_good, __pyx_v_descending, __pyx_v_sorted}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 282, __pyx_L5_error) + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { - __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 282, __pyx_L5_error) + __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 285, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; @@ -4001,12 +4009,12 @@ static PyObject *__pyx_pf_5trade_5Trade_4get_offers_all(struct __pyx_obj_5trade_ __Pyx_INCREF(__pyx_v_sorted); __Pyx_GIVEREF(__pyx_v_sorted); PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_v_sorted); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 282, __pyx_L5_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(PyDict_SetItem(__pyx_t_3, (PyObject*)__pyx_8genexpr2__pyx_v_good, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 282, __pyx_L5_error) + if (unlikely(PyDict_SetItem(__pyx_t_3, (PyObject*)__pyx_8genexpr2__pyx_v_good, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 285, __pyx_L5_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -4021,7 +4029,7 @@ static PyObject *__pyx_pf_5trade_5Trade_4get_offers_all(struct __pyx_obj_5trade_ __pyx_t_3 = 0; goto __pyx_L0; - /* "trade.pyx":247 + /* "trade.pyx":250 * return {good: self.get_offers(good, descending, sorted) for good in goods} * * def get_offers_all(self, descending=False, sorted=True): # <<<<<<<<<<<<<< @@ -4046,7 +4054,7 @@ static PyObject *__pyx_pf_5trade_5Trade_4get_offers_all(struct __pyx_obj_5trade_ return __pyx_r; } -/* "trade.pyx":284 +/* "trade.pyx":287 * return {good: self.get_offers(good, descending, sorted) for good in goods} * * def get_buy_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< @@ -4103,7 +4111,7 @@ static PyObject *__pyx_pw_5trade_5Trade_7get_buy_offers(PyObject *__pyx_v_self, } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_buy_offers") < 0)) __PYX_ERR(0, 284, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_buy_offers") < 0)) __PYX_ERR(0, 287, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -4122,7 +4130,7 @@ static PyObject *__pyx_pw_5trade_5Trade_7get_buy_offers(PyObject *__pyx_v_self, } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("get_buy_offers", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 284, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("get_buy_offers", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 287, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade.get_buy_offers", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -4135,7 +4143,7 @@ static PyObject *__pyx_pw_5trade_5Trade_7get_buy_offers(PyObject *__pyx_v_self, return __pyx_r; } -/* "trade.pyx":291 +/* "trade.pyx":294 * random.shuffle(ret) * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) # <<<<<<<<<<<<<< @@ -4163,7 +4171,7 @@ static PyObject *__pyx_lambda_funcdef_lambda(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("lambda", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_objects, __pyx_n_s_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_objects, __pyx_n_s_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -4180,7 +4188,7 @@ static PyObject *__pyx_lambda_funcdef_lambda(CYTHON_UNUSED PyObject *__pyx_self, return __pyx_r; } -/* "trade.pyx":284 +/* "trade.pyx":287 * return {good: self.get_offers(good, descending, sorted) for good in goods} * * def get_buy_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< @@ -4200,19 +4208,19 @@ static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers(struct __pyx_obj_5trade_ int __pyx_t_6; __Pyx_RefNannySetupContext("get_buy_offers", 0); - /* "trade.pyx":285 + /* "trade.pyx":288 * * def get_buy_offers(self, good, sorted=True, descending=False, shuffled=True): * ret = list(self._open_offers_buy[good].values()) # <<<<<<<<<<<<<< * self._polled_offers.update(self._open_offers_buy[good]) * del self._open_offers_buy[good] */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 285, __pyx_L1_error) + __pyx_t_3 = PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 288, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; @@ -4226,34 +4234,34 @@ static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers(struct __pyx_obj_5trade_ } } if (__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 288, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 288, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L1_error) + __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_ret = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":286 + /* "trade.pyx":289 * def get_buy_offers(self, good, sorted=True, descending=False, shuffled=True): * ret = list(self._open_offers_buy[good].values()) * self._polled_offers.update(self._open_offers_buy[good]) # <<<<<<<<<<<<<< * del self._open_offers_buy[good] * if shuffled: */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_polled_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_polled_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_update); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_update); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyObject_GetItem(__pyx_t_1, __pyx_v_good); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_4 = PyObject_GetItem(__pyx_t_1, __pyx_v_good); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; @@ -4267,14 +4275,14 @@ static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers(struct __pyx_obj_5trade_ } } if (!__pyx_t_1) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_4}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -4283,20 +4291,20 @@ static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers(struct __pyx_obj_5trade_ #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_4}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL; __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4); __pyx_t_4 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } @@ -4304,38 +4312,38 @@ static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers(struct __pyx_obj_5trade_ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":287 + /* "trade.pyx":290 * ret = list(self._open_offers_buy[good].values()) * self._polled_offers.update(self._open_offers_buy[good]) * del self._open_offers_buy[good] # <<<<<<<<<<<<<< * if shuffled: * random.shuffle(ret) */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 287, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 290, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (unlikely(PyObject_DelItem(__pyx_t_2, __pyx_v_good) < 0)) __PYX_ERR(0, 287, __pyx_L1_error) + if (unlikely(PyObject_DelItem(__pyx_t_2, __pyx_v_good) < 0)) __PYX_ERR(0, 290, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":288 + /* "trade.pyx":291 * self._polled_offers.update(self._open_offers_buy[good]) * del self._open_offers_buy[good] * if shuffled: # <<<<<<<<<<<<<< * random.shuffle(ret) * if sorted: */ - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_shuffled); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 288, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_shuffled); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 291, __pyx_L1_error) if (__pyx_t_6) { - /* "trade.pyx":289 + /* "trade.pyx":292 * del self._open_offers_buy[good] * if shuffled: * random.shuffle(ret) # <<<<<<<<<<<<<< * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 289, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 289, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; @@ -4349,13 +4357,13 @@ static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers(struct __pyx_obj_5trade_ } } if (!__pyx_t_3) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_ret); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_ret); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_ret}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 292, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_2); } else @@ -4363,19 +4371,19 @@ static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers(struct __pyx_obj_5trade_ #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_ret}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 292, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif { - __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 289, __pyx_L1_error) + __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_INCREF(__pyx_v_ret); __Pyx_GIVEREF(__pyx_v_ret); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_ret); - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } @@ -4383,7 +4391,7 @@ static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers(struct __pyx_obj_5trade_ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":288 + /* "trade.pyx":291 * self._polled_offers.update(self._open_offers_buy[good]) * del self._open_offers_buy[good] * if shuffled: # <<<<<<<<<<<<<< @@ -4392,39 +4400,39 @@ static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers(struct __pyx_obj_5trade_ */ } - /* "trade.pyx":290 + /* "trade.pyx":293 * if shuffled: * random.shuffle(ret) * if sorted: # <<<<<<<<<<<<<< * ret.sort(key=lambda objects: objects.price, reverse=descending) * return ret */ - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_sorted); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 290, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_sorted); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 293, __pyx_L1_error) if (__pyx_t_6) { - /* "trade.pyx":291 + /* "trade.pyx":294 * random.shuffle(ret) * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) # <<<<<<<<<<<<<< * return ret * */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ret, __pyx_n_s_sort); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ret, __pyx_n_s_sort); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_14get_buy_offers_lambda, 0, __pyx_n_s_get_buy_offers_locals_lambda, NULL, __pyx_n_s_trade, __pyx_d, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 291, __pyx_L1_error) + __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_14get_buy_offers_lambda, 0, __pyx_n_s_get_buy_offers_locals_lambda, NULL, __pyx_n_s_trade, __pyx_d, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_key, __pyx_t_4) < 0) __PYX_ERR(0, 291, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_key, __pyx_t_4) < 0) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_reverse, __pyx_v_descending) < 0) __PYX_ERR(0, 291, __pyx_L1_error) - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 291, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_reverse, __pyx_v_descending) < 0) __PYX_ERR(0, 294, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "trade.pyx":290 + /* "trade.pyx":293 * if shuffled: * random.shuffle(ret) * if sorted: # <<<<<<<<<<<<<< @@ -4433,7 +4441,7 @@ static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers(struct __pyx_obj_5trade_ */ } - /* "trade.pyx":292 + /* "trade.pyx":295 * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) * return ret # <<<<<<<<<<<<<< @@ -4445,7 +4453,7 @@ static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers(struct __pyx_obj_5trade_ __pyx_r = __pyx_v_ret; goto __pyx_L0; - /* "trade.pyx":284 + /* "trade.pyx":287 * return {good: self.get_offers(good, descending, sorted) for good in goods} * * def get_buy_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< @@ -4469,7 +4477,7 @@ static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers(struct __pyx_obj_5trade_ return __pyx_r; } -/* "trade.pyx":294 +/* "trade.pyx":297 * return ret * * def get_sell_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< @@ -4526,7 +4534,7 @@ static PyObject *__pyx_pw_5trade_5Trade_9get_sell_offers(PyObject *__pyx_v_self, } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_sell_offers") < 0)) __PYX_ERR(0, 294, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_sell_offers") < 0)) __PYX_ERR(0, 297, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -4545,7 +4553,7 @@ static PyObject *__pyx_pw_5trade_5Trade_9get_sell_offers(PyObject *__pyx_v_self, } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("get_sell_offers", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 294, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("get_sell_offers", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 297, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade.get_sell_offers", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -4558,7 +4566,7 @@ static PyObject *__pyx_pw_5trade_5Trade_9get_sell_offers(PyObject *__pyx_v_self, return __pyx_r; } -/* "trade.pyx":301 +/* "trade.pyx":304 * random.shuffle(ret) * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) # <<<<<<<<<<<<<< @@ -4586,7 +4594,7 @@ static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("lambda1", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_objects, __pyx_n_s_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 301, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_objects, __pyx_n_s_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -4603,7 +4611,7 @@ static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self return __pyx_r; } -/* "trade.pyx":294 +/* "trade.pyx":297 * return ret * * def get_sell_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< @@ -4623,19 +4631,19 @@ static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers(struct __pyx_obj_5trade int __pyx_t_6; __Pyx_RefNannySetupContext("get_sell_offers", 0); - /* "trade.pyx":295 + /* "trade.pyx":298 * * def get_sell_offers(self, good, sorted=True, descending=False, shuffled=True): * ret = list(self._open_offers_sell[good].values()) # <<<<<<<<<<<<<< * self._polled_offers.update(self._open_offers_sell[good]) * del self._open_offers_sell[good] */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 295, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 295, __pyx_L1_error) + __pyx_t_3 = PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 295, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; @@ -4649,34 +4657,34 @@ static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers(struct __pyx_obj_5trade } } if (__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 295, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 295, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 298, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 295, __pyx_L1_error) + __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_ret = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":296 + /* "trade.pyx":299 * def get_sell_offers(self, good, sorted=True, descending=False, shuffled=True): * ret = list(self._open_offers_sell[good].values()) * self._polled_offers.update(self._open_offers_sell[good]) # <<<<<<<<<<<<<< * del self._open_offers_sell[good] * if shuffled: */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_polled_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_polled_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 299, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_update); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 296, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_update); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 299, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 299, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyObject_GetItem(__pyx_t_1, __pyx_v_good); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 296, __pyx_L1_error) + __pyx_t_4 = PyObject_GetItem(__pyx_t_1, __pyx_v_good); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 299, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; @@ -4690,14 +4698,14 @@ static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers(struct __pyx_obj_5trade } } if (!__pyx_t_1) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 296, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 299, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_4}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 296, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 299, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -4706,20 +4714,20 @@ static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers(struct __pyx_obj_5trade #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_4}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 296, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 299, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 296, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 299, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL; __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4); __pyx_t_4 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 296, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 299, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } @@ -4727,38 +4735,38 @@ static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers(struct __pyx_obj_5trade __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":297 + /* "trade.pyx":300 * ret = list(self._open_offers_sell[good].values()) * self._polled_offers.update(self._open_offers_sell[good]) * del self._open_offers_sell[good] # <<<<<<<<<<<<<< * if shuffled: * random.shuffle(ret) */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 297, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 300, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (unlikely(PyObject_DelItem(__pyx_t_2, __pyx_v_good) < 0)) __PYX_ERR(0, 297, __pyx_L1_error) + if (unlikely(PyObject_DelItem(__pyx_t_2, __pyx_v_good) < 0)) __PYX_ERR(0, 300, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":298 + /* "trade.pyx":301 * self._polled_offers.update(self._open_offers_sell[good]) * del self._open_offers_sell[good] * if shuffled: # <<<<<<<<<<<<<< * random.shuffle(ret) * if sorted: */ - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_shuffled); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 298, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_shuffled); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 301, __pyx_L1_error) if (__pyx_t_6) { - /* "trade.pyx":299 + /* "trade.pyx":302 * del self._open_offers_sell[good] * if shuffled: * random.shuffle(ret) # <<<<<<<<<<<<<< * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 299, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 299, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; @@ -4772,13 +4780,13 @@ static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers(struct __pyx_obj_5trade } } if (!__pyx_t_3) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_ret); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 299, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_ret); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_ret}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 299, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_2); } else @@ -4786,19 +4794,19 @@ static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers(struct __pyx_obj_5trade #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_ret}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 299, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif { - __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 299, __pyx_L1_error) + __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; __Pyx_INCREF(__pyx_v_ret); __Pyx_GIVEREF(__pyx_v_ret); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_ret); - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 299, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } @@ -4806,7 +4814,7 @@ static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers(struct __pyx_obj_5trade __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":298 + /* "trade.pyx":301 * self._polled_offers.update(self._open_offers_sell[good]) * del self._open_offers_sell[good] * if shuffled: # <<<<<<<<<<<<<< @@ -4815,39 +4823,39 @@ static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers(struct __pyx_obj_5trade */ } - /* "trade.pyx":300 + /* "trade.pyx":303 * if shuffled: * random.shuffle(ret) * if sorted: # <<<<<<<<<<<<<< * ret.sort(key=lambda objects: objects.price, reverse=descending) * return ret */ - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_sorted); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 300, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_sorted); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 303, __pyx_L1_error) if (__pyx_t_6) { - /* "trade.pyx":301 + /* "trade.pyx":304 * random.shuffle(ret) * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) # <<<<<<<<<<<<<< * return ret * */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ret, __pyx_n_s_sort); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 301, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ret, __pyx_n_s_sort); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 301, __pyx_L1_error) + __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_15get_sell_offers_lambda1, 0, __pyx_n_s_get_sell_offers_locals_lambda, NULL, __pyx_n_s_trade, __pyx_d, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error) + __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_15get_sell_offers_lambda1, 0, __pyx_n_s_get_sell_offers_locals_lambda, NULL, __pyx_n_s_trade, __pyx_d, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_key, __pyx_t_4) < 0) __PYX_ERR(0, 301, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_key, __pyx_t_4) < 0) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_reverse, __pyx_v_descending) < 0) __PYX_ERR(0, 301, __pyx_L1_error) - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_reverse, __pyx_v_descending) < 0) __PYX_ERR(0, 304, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "trade.pyx":300 + /* "trade.pyx":303 * if shuffled: * random.shuffle(ret) * if sorted: # <<<<<<<<<<<<<< @@ -4856,7 +4864,7 @@ static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers(struct __pyx_obj_5trade */ } - /* "trade.pyx":302 + /* "trade.pyx":305 * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) * return ret # <<<<<<<<<<<<<< @@ -4868,7 +4876,7 @@ static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers(struct __pyx_obj_5trade __pyx_r = __pyx_v_ret; goto __pyx_L0; - /* "trade.pyx":294 + /* "trade.pyx":297 * return ret * * def get_sell_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< @@ -4892,7 +4900,7 @@ static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers(struct __pyx_obj_5trade return __pyx_r; } -/* "trade.pyx":304 +/* "trade.pyx":307 * return ret * * def get_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< @@ -4950,7 +4958,7 @@ static PyObject *__pyx_pw_5trade_5Trade_11get_offers(PyObject *__pyx_v_self, PyO } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_offers") < 0)) __PYX_ERR(0, 304, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_offers") < 0)) __PYX_ERR(0, 307, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -4969,7 +4977,7 @@ static PyObject *__pyx_pw_5trade_5Trade_11get_offers(PyObject *__pyx_v_self, PyO } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("get_offers", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 304, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("get_offers", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 307, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade.get_offers", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -4982,7 +4990,7 @@ static PyObject *__pyx_pw_5trade_5Trade_11get_offers(PyObject *__pyx_v_self, PyO return __pyx_r; } -/* "trade.pyx":347 +/* "trade.pyx":350 * random.shuffle(ret) * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) # <<<<<<<<<<<<<< @@ -5010,7 +5018,7 @@ static PyObject *__pyx_lambda_funcdef_lambda2(CYTHON_UNUSED PyObject *__pyx_self PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("lambda2", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_objects, __pyx_n_s_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_objects, __pyx_n_s_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 350, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -5027,7 +5035,7 @@ static PyObject *__pyx_lambda_funcdef_lambda2(CYTHON_UNUSED PyObject *__pyx_self return __pyx_r; } -/* "trade.pyx":304 +/* "trade.pyx":307 * return ret * * def get_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< @@ -5047,90 +5055,90 @@ static PyObject *__pyx_pf_5trade_5Trade_10get_offers(struct __pyx_obj_5trade_Tra int __pyx_t_6; __Pyx_RefNannySetupContext("get_offers", 0); - /* "trade.pyx":342 + /* "trade.pyx":345 * self.reject(offer) # optional * """ * ret = (self.get_buy_offers(good, descending=False, sorted=False, shuffled=False) + # <<<<<<<<<<<<<< * self.get_sell_offers(good, descending=False, sorted=False, shuffled=False)) * if shuffled: */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_buy_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 342, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_buy_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 342, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_good); __Pyx_GIVEREF(__pyx_v_good); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_good); - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 342, __pyx_L1_error) + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_descending, Py_False) < 0) __PYX_ERR(0, 342, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_sorted, Py_False) < 0) __PYX_ERR(0, 342, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_shuffled, Py_False) < 0) __PYX_ERR(0, 342, __pyx_L1_error) - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 342, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_descending, Py_False) < 0) __PYX_ERR(0, 345, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_sorted, Py_False) < 0) __PYX_ERR(0, 345, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_shuffled, Py_False) < 0) __PYX_ERR(0, 345, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "trade.pyx":343 + /* "trade.pyx":346 * """ * ret = (self.get_buy_offers(good, descending=False, sorted=False, shuffled=False) + * self.get_sell_offers(good, descending=False, sorted=False, shuffled=False)) # <<<<<<<<<<<<<< * if shuffled: * random.shuffle(ret) */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_sell_offers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 343, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_sell_offers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 346, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 343, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 346, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_good); __Pyx_GIVEREF(__pyx_v_good); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_good); - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L1_error) + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 346, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_descending, Py_False) < 0) __PYX_ERR(0, 343, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_sorted, Py_False) < 0) __PYX_ERR(0, 343, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_shuffled, Py_False) < 0) __PYX_ERR(0, 343, __pyx_L1_error) - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 343, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_descending, Py_False) < 0) __PYX_ERR(0, 346, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_sorted, Py_False) < 0) __PYX_ERR(0, 346, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_shuffled, Py_False) < 0) __PYX_ERR(0, 346, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 346, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":342 + /* "trade.pyx":345 * self.reject(offer) # optional * """ * ret = (self.get_buy_offers(good, descending=False, sorted=False, shuffled=False) + # <<<<<<<<<<<<<< * self.get_sell_offers(good, descending=False, sorted=False, shuffled=False)) * if shuffled: */ - __pyx_t_1 = PyNumber_Add(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 342, __pyx_L1_error) + __pyx_t_1 = PyNumber_Add(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_ret = __pyx_t_1; __pyx_t_1 = 0; - /* "trade.pyx":344 + /* "trade.pyx":347 * ret = (self.get_buy_offers(good, descending=False, sorted=False, shuffled=False) + * self.get_sell_offers(good, descending=False, sorted=False, shuffled=False)) * if shuffled: # <<<<<<<<<<<<<< * random.shuffle(ret) * if sorted: */ - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_shuffled); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 344, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_shuffled); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 347, __pyx_L1_error) if (__pyx_t_6) { - /* "trade.pyx":345 + /* "trade.pyx":348 * self.get_sell_offers(good, descending=False, sorted=False, shuffled=False)) * if shuffled: * random.shuffle(ret) # <<<<<<<<<<<<<< * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 345, __pyx_L1_error) + __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 345, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; @@ -5144,13 +5152,13 @@ static PyObject *__pyx_pf_5trade_5Trade_10get_offers(struct __pyx_obj_5trade_Tra } } if (!__pyx_t_5) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_ret); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 345, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_ret); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_ret}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 345, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 348, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); } else @@ -5158,19 +5166,19 @@ static PyObject *__pyx_pf_5trade_5Trade_10get_offers(struct __pyx_obj_5trade_Tra #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_ret}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 345, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 348, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { - __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 345, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __pyx_t_5 = NULL; __Pyx_INCREF(__pyx_v_ret); __Pyx_GIVEREF(__pyx_v_ret); PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_ret); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 345, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } @@ -5178,7 +5186,7 @@ static PyObject *__pyx_pf_5trade_5Trade_10get_offers(struct __pyx_obj_5trade_Tra __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":344 + /* "trade.pyx":347 * ret = (self.get_buy_offers(good, descending=False, sorted=False, shuffled=False) + * self.get_sell_offers(good, descending=False, sorted=False, shuffled=False)) * if shuffled: # <<<<<<<<<<<<<< @@ -5187,39 +5195,39 @@ static PyObject *__pyx_pf_5trade_5Trade_10get_offers(struct __pyx_obj_5trade_Tra */ } - /* "trade.pyx":346 + /* "trade.pyx":349 * if shuffled: * random.shuffle(ret) * if sorted: # <<<<<<<<<<<<<< * ret.sort(key=lambda objects: objects.price, reverse=descending) * return ret */ - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_sorted); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 346, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_sorted); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 349, __pyx_L1_error) if (__pyx_t_6) { - /* "trade.pyx":347 + /* "trade.pyx":350 * random.shuffle(ret) * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) # <<<<<<<<<<<<<< * return ret * */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_ret, __pyx_n_s_sort); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_ret, __pyx_n_s_sort); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 350, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 347, __pyx_L1_error) + __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 350, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_10get_offers_lambda2, 0, __pyx_n_s_get_offers_locals_lambda, NULL, __pyx_n_s_trade, __pyx_d, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 347, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_10get_offers_lambda2, 0, __pyx_n_s_get_offers_locals_lambda, NULL, __pyx_n_s_trade, __pyx_d, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 350, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_key, __pyx_t_2) < 0) __PYX_ERR(0, 347, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_key, __pyx_t_2) < 0) __PYX_ERR(0, 350, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_reverse, __pyx_v_descending) < 0) __PYX_ERR(0, 347, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 347, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_reverse, __pyx_v_descending) < 0) __PYX_ERR(0, 350, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 350, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":346 + /* "trade.pyx":349 * if shuffled: * random.shuffle(ret) * if sorted: # <<<<<<<<<<<<<< @@ -5228,7 +5236,7 @@ static PyObject *__pyx_pf_5trade_5Trade_10get_offers(struct __pyx_obj_5trade_Tra */ } - /* "trade.pyx":348 + /* "trade.pyx":351 * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) * return ret # <<<<<<<<<<<<<< @@ -5240,7 +5248,7 @@ static PyObject *__pyx_pf_5trade_5Trade_10get_offers(struct __pyx_obj_5trade_Tra __pyx_r = __pyx_v_ret; goto __pyx_L0; - /* "trade.pyx":304 + /* "trade.pyx":307 * return ret * * def get_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< @@ -5264,7 +5272,7 @@ static PyObject *__pyx_pf_5trade_5Trade_10get_offers(struct __pyx_obj_5trade_Tra return __pyx_r; } -/* "trade.pyx":350 +/* "trade.pyx":353 * return ret * * def peak_buy_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< @@ -5321,7 +5329,7 @@ static PyObject *__pyx_pw_5trade_5Trade_13peak_buy_offers(PyObject *__pyx_v_self } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "peak_buy_offers") < 0)) __PYX_ERR(0, 350, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "peak_buy_offers") < 0)) __PYX_ERR(0, 353, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -5340,7 +5348,7 @@ static PyObject *__pyx_pw_5trade_5Trade_13peak_buy_offers(PyObject *__pyx_v_self } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("peak_buy_offers", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 350, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("peak_buy_offers", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 353, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade.peak_buy_offers", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -5353,7 +5361,7 @@ static PyObject *__pyx_pw_5trade_5Trade_13peak_buy_offers(PyObject *__pyx_v_self return __pyx_r; } -/* "trade.pyx":357 +/* "trade.pyx":360 * random.shuffle(ret) * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) # <<<<<<<<<<<<<< @@ -5381,7 +5389,7 @@ static PyObject *__pyx_lambda_funcdef_lambda3(CYTHON_UNUSED PyObject *__pyx_self PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("lambda3", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_objects, __pyx_n_s_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 357, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_objects, __pyx_n_s_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -5398,7 +5406,7 @@ static PyObject *__pyx_lambda_funcdef_lambda3(CYTHON_UNUSED PyObject *__pyx_self return __pyx_r; } -/* "trade.pyx":350 +/* "trade.pyx":353 * return ret * * def peak_buy_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< @@ -5421,31 +5429,31 @@ static PyObject *__pyx_pf_5trade_5Trade_12peak_buy_offers(struct __pyx_obj_5trad PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("peak_buy_offers", 0); - /* "trade.pyx":351 + /* "trade.pyx":354 * * def peak_buy_offers(self, good, sorted=True, descending=False, shuffled=True): * ret = [] # <<<<<<<<<<<<<< * for offer in self._open_offers_buy[good].values(): * ret.append(offer) */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 351, __pyx_L1_error) + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 354, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_ret = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":352 + /* "trade.pyx":355 * def peak_buy_offers(self, good, sorted=True, descending=False, shuffled=True): * ret = [] * for offer in self._open_offers_buy[good].values(): # <<<<<<<<<<<<<< * ret.append(offer) * if shuffled: */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 352, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 352, __pyx_L1_error) + __pyx_t_3 = PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 352, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; @@ -5459,10 +5467,10 @@ static PyObject *__pyx_pf_5trade_5Trade_12peak_buy_offers(struct __pyx_obj_5trad } } if (__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 352, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 355, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 352, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 355, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -5470,9 +5478,9 @@ static PyObject *__pyx_pf_5trade_5Trade_12peak_buy_offers(struct __pyx_obj_5trad __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { - __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 352, __pyx_L1_error) + __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 352, __pyx_L1_error) + __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 355, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { @@ -5480,17 +5488,17 @@ static PyObject *__pyx_pf_5trade_5Trade_12peak_buy_offers(struct __pyx_obj_5trad if (likely(PyList_CheckExact(__pyx_t_2))) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 352, __pyx_L1_error) + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 355, __pyx_L1_error) #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 352, __pyx_L1_error) + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 352, __pyx_L1_error) + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 355, __pyx_L1_error) #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 352, __pyx_L1_error) + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } @@ -5500,7 +5508,7 @@ static PyObject *__pyx_pf_5trade_5Trade_12peak_buy_offers(struct __pyx_obj_5trad PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 352, __pyx_L1_error) + else __PYX_ERR(0, 355, __pyx_L1_error) } break; } @@ -5509,16 +5517,16 @@ static PyObject *__pyx_pf_5trade_5Trade_12peak_buy_offers(struct __pyx_obj_5trad __Pyx_XDECREF_SET(__pyx_v_offer, __pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":353 + /* "trade.pyx":356 * ret = [] * for offer in self._open_offers_buy[good].values(): * ret.append(offer) # <<<<<<<<<<<<<< * if shuffled: * random.shuffle(ret) */ - __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_v_offer); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 353, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_v_offer); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 356, __pyx_L1_error) - /* "trade.pyx":352 + /* "trade.pyx":355 * def peak_buy_offers(self, good, sorted=True, descending=False, shuffled=True): * ret = [] * for offer in self._open_offers_buy[good].values(): # <<<<<<<<<<<<<< @@ -5528,26 +5536,26 @@ static PyObject *__pyx_pf_5trade_5Trade_12peak_buy_offers(struct __pyx_obj_5trad } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":354 + /* "trade.pyx":357 * for offer in self._open_offers_buy[good].values(): * ret.append(offer) * if shuffled: # <<<<<<<<<<<<<< * random.shuffle(ret) * if sorted: */ - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_shuffled); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 354, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_shuffled); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 357, __pyx_L1_error) if (__pyx_t_7) { - /* "trade.pyx":355 + /* "trade.pyx":358 * ret.append(offer) * if shuffled: * random.shuffle(ret) # <<<<<<<<<<<<<< * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 355, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 358, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 355, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 358, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; @@ -5561,13 +5569,13 @@ static PyObject *__pyx_pf_5trade_5Trade_12peak_buy_offers(struct __pyx_obj_5trad } } if (!__pyx_t_1) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_ret); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 355, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_ret); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 358, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_ret}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 355, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 358, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_2); } else @@ -5575,19 +5583,19 @@ static PyObject *__pyx_pf_5trade_5Trade_12peak_buy_offers(struct __pyx_obj_5trad #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_ret}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 355, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 358, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif { - __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 355, __pyx_L1_error) + __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 358, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); __pyx_t_1 = NULL; __Pyx_INCREF(__pyx_v_ret); __Pyx_GIVEREF(__pyx_v_ret); PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_ret); - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 355, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 358, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } @@ -5595,7 +5603,7 @@ static PyObject *__pyx_pf_5trade_5Trade_12peak_buy_offers(struct __pyx_obj_5trad __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":354 + /* "trade.pyx":357 * for offer in self._open_offers_buy[good].values(): * ret.append(offer) * if shuffled: # <<<<<<<<<<<<<< @@ -5604,39 +5612,39 @@ static PyObject *__pyx_pf_5trade_5Trade_12peak_buy_offers(struct __pyx_obj_5trad */ } - /* "trade.pyx":356 + /* "trade.pyx":359 * if shuffled: * random.shuffle(ret) * if sorted: # <<<<<<<<<<<<<< * ret.sort(key=lambda objects: objects.price, reverse=descending) * return ret */ - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_sorted); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 356, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_sorted); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 359, __pyx_L1_error) if (__pyx_t_7) { - /* "trade.pyx":357 + /* "trade.pyx":360 * random.shuffle(ret) * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) # <<<<<<<<<<<<<< * return ret * */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ret, __pyx_n_s_sort); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 357, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ret, __pyx_n_s_sort); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 360, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 357, __pyx_L1_error) + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 360, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_8 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_15peak_buy_offers_lambda3, 0, __pyx_n_s_peak_buy_offers_locals_lambda, NULL, __pyx_n_s_trade, __pyx_d, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 357, __pyx_L1_error) + __pyx_t_8 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_15peak_buy_offers_lambda3, 0, __pyx_n_s_peak_buy_offers_locals_lambda, NULL, __pyx_n_s_trade, __pyx_d, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 360, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_key, __pyx_t_8) < 0) __PYX_ERR(0, 357, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_key, __pyx_t_8) < 0) __PYX_ERR(0, 360, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reverse, __pyx_v_descending) < 0) __PYX_ERR(0, 357, __pyx_L1_error) - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 357, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reverse, __pyx_v_descending) < 0) __PYX_ERR(0, 360, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 360, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - /* "trade.pyx":356 + /* "trade.pyx":359 * if shuffled: * random.shuffle(ret) * if sorted: # <<<<<<<<<<<<<< @@ -5645,7 +5653,7 @@ static PyObject *__pyx_pf_5trade_5Trade_12peak_buy_offers(struct __pyx_obj_5trad */ } - /* "trade.pyx":358 + /* "trade.pyx":361 * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) * return ret # <<<<<<<<<<<<<< @@ -5657,7 +5665,7 @@ static PyObject *__pyx_pf_5trade_5Trade_12peak_buy_offers(struct __pyx_obj_5trad __pyx_r = __pyx_v_ret; goto __pyx_L0; - /* "trade.pyx":350 + /* "trade.pyx":353 * return ret * * def peak_buy_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< @@ -5681,7 +5689,7 @@ static PyObject *__pyx_pf_5trade_5Trade_12peak_buy_offers(struct __pyx_obj_5trad return __pyx_r; } -/* "trade.pyx":360 +/* "trade.pyx":363 * return ret * * def peak_sell_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< @@ -5738,7 +5746,7 @@ static PyObject *__pyx_pw_5trade_5Trade_15peak_sell_offers(PyObject *__pyx_v_sel } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "peak_sell_offers") < 0)) __PYX_ERR(0, 360, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "peak_sell_offers") < 0)) __PYX_ERR(0, 363, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -5757,7 +5765,7 @@ static PyObject *__pyx_pw_5trade_5Trade_15peak_sell_offers(PyObject *__pyx_v_sel } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("peak_sell_offers", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 360, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("peak_sell_offers", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 363, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade.peak_sell_offers", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -5770,7 +5778,7 @@ static PyObject *__pyx_pw_5trade_5Trade_15peak_sell_offers(PyObject *__pyx_v_sel return __pyx_r; } -/* "trade.pyx":367 +/* "trade.pyx":370 * random.shuffle(ret) * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) # <<<<<<<<<<<<<< @@ -5798,7 +5806,7 @@ static PyObject *__pyx_lambda_funcdef_lambda4(CYTHON_UNUSED PyObject *__pyx_self PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("lambda4", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_objects, __pyx_n_s_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 367, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_objects, __pyx_n_s_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 370, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -5815,7 +5823,7 @@ static PyObject *__pyx_lambda_funcdef_lambda4(CYTHON_UNUSED PyObject *__pyx_self return __pyx_r; } -/* "trade.pyx":360 +/* "trade.pyx":363 * return ret * * def peak_sell_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< @@ -5838,31 +5846,31 @@ static PyObject *__pyx_pf_5trade_5Trade_14peak_sell_offers(struct __pyx_obj_5tra PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("peak_sell_offers", 0); - /* "trade.pyx":361 + /* "trade.pyx":364 * * def peak_sell_offers(self, good, sorted=True, descending=False, shuffled=True): * ret = [] # <<<<<<<<<<<<<< * for offer in self._open_offers_sell[good].values(): * ret.append(offer) */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 361, __pyx_L1_error) + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 364, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_ret = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":362 + /* "trade.pyx":365 * def peak_sell_offers(self, good, sorted=True, descending=False, shuffled=True): * ret = [] * for offer in self._open_offers_sell[good].values(): # <<<<<<<<<<<<<< * ret.append(offer) * if shuffled: */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 362, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 362, __pyx_L1_error) + __pyx_t_3 = PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 362, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; @@ -5876,10 +5884,10 @@ static PyObject *__pyx_pf_5trade_5Trade_14peak_sell_offers(struct __pyx_obj_5tra } } if (__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 362, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 362, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -5887,9 +5895,9 @@ static PyObject *__pyx_pf_5trade_5Trade_14peak_sell_offers(struct __pyx_obj_5tra __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { - __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 362, __pyx_L1_error) + __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 362, __pyx_L1_error) + __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 365, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { @@ -5897,17 +5905,17 @@ static PyObject *__pyx_pf_5trade_5Trade_14peak_sell_offers(struct __pyx_obj_5tra if (likely(PyList_CheckExact(__pyx_t_2))) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 362, __pyx_L1_error) + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 365, __pyx_L1_error) #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 362, __pyx_L1_error) + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 362, __pyx_L1_error) + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 365, __pyx_L1_error) #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 362, __pyx_L1_error) + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } @@ -5917,7 +5925,7 @@ static PyObject *__pyx_pf_5trade_5Trade_14peak_sell_offers(struct __pyx_obj_5tra PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 362, __pyx_L1_error) + else __PYX_ERR(0, 365, __pyx_L1_error) } break; } @@ -5926,16 +5934,16 @@ static PyObject *__pyx_pf_5trade_5Trade_14peak_sell_offers(struct __pyx_obj_5tra __Pyx_XDECREF_SET(__pyx_v_offer, __pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":363 + /* "trade.pyx":366 * ret = [] * for offer in self._open_offers_sell[good].values(): * ret.append(offer) # <<<<<<<<<<<<<< * if shuffled: * random.shuffle(ret) */ - __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_v_offer); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 363, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_v_offer); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 366, __pyx_L1_error) - /* "trade.pyx":362 + /* "trade.pyx":365 * def peak_sell_offers(self, good, sorted=True, descending=False, shuffled=True): * ret = [] * for offer in self._open_offers_sell[good].values(): # <<<<<<<<<<<<<< @@ -5945,26 +5953,26 @@ static PyObject *__pyx_pf_5trade_5Trade_14peak_sell_offers(struct __pyx_obj_5tra } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":364 + /* "trade.pyx":367 * for offer in self._open_offers_sell[good].values(): * ret.append(offer) * if shuffled: # <<<<<<<<<<<<<< * random.shuffle(ret) * if sorted: */ - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_shuffled); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 364, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_shuffled); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 367, __pyx_L1_error) if (__pyx_t_7) { - /* "trade.pyx":365 + /* "trade.pyx":368 * ret.append(offer) * if shuffled: * random.shuffle(ret) # <<<<<<<<<<<<<< * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; @@ -5978,13 +5986,13 @@ static PyObject *__pyx_pf_5trade_5Trade_14peak_sell_offers(struct __pyx_obj_5tra } } if (!__pyx_t_1) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_ret); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_ret); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_ret}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 368, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_2); } else @@ -5992,19 +6000,19 @@ static PyObject *__pyx_pf_5trade_5Trade_14peak_sell_offers(struct __pyx_obj_5tra #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_ret}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 368, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif { - __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); __pyx_t_1 = NULL; __Pyx_INCREF(__pyx_v_ret); __Pyx_GIVEREF(__pyx_v_ret); PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_ret); - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 365, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } @@ -6012,7 +6020,7 @@ static PyObject *__pyx_pf_5trade_5Trade_14peak_sell_offers(struct __pyx_obj_5tra __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":364 + /* "trade.pyx":367 * for offer in self._open_offers_sell[good].values(): * ret.append(offer) * if shuffled: # <<<<<<<<<<<<<< @@ -6021,39 +6029,39 @@ static PyObject *__pyx_pf_5trade_5Trade_14peak_sell_offers(struct __pyx_obj_5tra */ } - /* "trade.pyx":366 + /* "trade.pyx":369 * if shuffled: * random.shuffle(ret) * if sorted: # <<<<<<<<<<<<<< * ret.sort(key=lambda objects: objects.price, reverse=descending) * return ret */ - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_sorted); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 366, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_sorted); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 369, __pyx_L1_error) if (__pyx_t_7) { - /* "trade.pyx":367 + /* "trade.pyx":370 * random.shuffle(ret) * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) # <<<<<<<<<<<<<< * return ret * */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ret, __pyx_n_s_sort); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 367, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ret, __pyx_n_s_sort); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 370, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 367, __pyx_L1_error) + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 370, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_8 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_16peak_sell_offers_lambda4, 0, __pyx_n_s_peak_sell_offers_locals_lambda, NULL, __pyx_n_s_trade, __pyx_d, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 367, __pyx_L1_error) + __pyx_t_8 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_16peak_sell_offers_lambda4, 0, __pyx_n_s_peak_sell_offers_locals_lambda, NULL, __pyx_n_s_trade, __pyx_d, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 370, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_key, __pyx_t_8) < 0) __PYX_ERR(0, 367, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_key, __pyx_t_8) < 0) __PYX_ERR(0, 370, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reverse, __pyx_v_descending) < 0) __PYX_ERR(0, 367, __pyx_L1_error) - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 367, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reverse, __pyx_v_descending) < 0) __PYX_ERR(0, 370, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 370, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - /* "trade.pyx":366 + /* "trade.pyx":369 * if shuffled: * random.shuffle(ret) * if sorted: # <<<<<<<<<<<<<< @@ -6062,7 +6070,7 @@ static PyObject *__pyx_pf_5trade_5Trade_14peak_sell_offers(struct __pyx_obj_5tra */ } - /* "trade.pyx":368 + /* "trade.pyx":371 * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) * return ret # <<<<<<<<<<<<<< @@ -6074,7 +6082,7 @@ static PyObject *__pyx_pf_5trade_5Trade_14peak_sell_offers(struct __pyx_obj_5tra __pyx_r = __pyx_v_ret; goto __pyx_L0; - /* "trade.pyx":360 + /* "trade.pyx":363 * return ret * * def peak_sell_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< @@ -6098,7 +6106,7 @@ static PyObject *__pyx_pf_5trade_5Trade_14peak_sell_offers(struct __pyx_obj_5tra return __pyx_r; } -/* "trade.pyx":370 +/* "trade.pyx":373 * return ret * * def peak_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< @@ -6108,7 +6116,7 @@ static PyObject *__pyx_pf_5trade_5Trade_14peak_sell_offers(struct __pyx_obj_5tra /* Python wrapper */ static PyObject *__pyx_pw_5trade_5Trade_17peak_offers(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_5trade_5Trade_16peak_offers[] = " returns a peak on all offers of the 'good' ordered by price.\n Peaked offers can not be accepted or rejected and they do not\n expire.\n\n Args:\n good:\n the good which should be retrieved\n descending(bool,default=False):\n False for descending True for ascending by price\n\n Returns:\n A list of offers ordered by price\n\n Example::\n\n offers = get_offers('books')\n for offer in offers:\n if offer.price < 50:\n self.accept(offer)\n elif offer.price < 100:\n self.accept(offer, 1)\n else:\n self.reject(offer) # optional\n "; +static char __pyx_doc_5trade_5Trade_16peak_offers[] = " returns a peak on all offers of the 'good' ordered by price.\n Peaked offers can not be accepted or rejected and they do not\n expire.\n\n Args:\n good:\n the good which should be retrieved\n descending(bool, default=False):\n False for descending True for ascending by price\n\n Returns:\n A list of offers ordered by price\n\n Example::\n\n offers = get_offers('books')\n for offer in offers:\n if offer.price < 50:\n self.accept(offer)\n elif offer.price < 100:\n self.accept(offer, 1)\n else:\n self.reject(offer) # optional\n "; static PyObject *__pyx_pw_5trade_5Trade_17peak_offers(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_good = 0; PyObject *__pyx_v_sorted = 0; @@ -6156,7 +6164,7 @@ static PyObject *__pyx_pw_5trade_5Trade_17peak_offers(PyObject *__pyx_v_self, Py } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "peak_offers") < 0)) __PYX_ERR(0, 370, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "peak_offers") < 0)) __PYX_ERR(0, 373, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -6175,7 +6183,7 @@ static PyObject *__pyx_pw_5trade_5Trade_17peak_offers(PyObject *__pyx_v_self, Py } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("peak_offers", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 370, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("peak_offers", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 373, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade.peak_offers", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -6188,7 +6196,7 @@ static PyObject *__pyx_pw_5trade_5Trade_17peak_offers(PyObject *__pyx_v_self, Py return __pyx_r; } -/* "trade.pyx":400 +/* "trade.pyx":403 * random.shuffle(ret) * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) # <<<<<<<<<<<<<< @@ -6216,7 +6224,7 @@ static PyObject *__pyx_lambda_funcdef_lambda5(CYTHON_UNUSED PyObject *__pyx_self PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("lambda5", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_objects, __pyx_n_s_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 400, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_objects, __pyx_n_s_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -6233,7 +6241,7 @@ static PyObject *__pyx_lambda_funcdef_lambda5(CYTHON_UNUSED PyObject *__pyx_self return __pyx_r; } -/* "trade.pyx":370 +/* "trade.pyx":373 * return ret * * def peak_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< @@ -6253,90 +6261,90 @@ static PyObject *__pyx_pf_5trade_5Trade_16peak_offers(struct __pyx_obj_5trade_Tr int __pyx_t_6; __Pyx_RefNannySetupContext("peak_offers", 0); - /* "trade.pyx":395 + /* "trade.pyx":398 * self.reject(offer) # optional * """ * ret = (self.peak_buy_offers(good, sorted=False, descending=False, shuffled=False) + # <<<<<<<<<<<<<< * self.peak_sell_offers(good, sorted=False, descending=False, shuffled=False)) * if shuffled: */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_peak_buy_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 395, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_peak_buy_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 398, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 395, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 398, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_good); __Pyx_GIVEREF(__pyx_v_good); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_good); - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 395, __pyx_L1_error) + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 398, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_sorted, Py_False) < 0) __PYX_ERR(0, 395, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_descending, Py_False) < 0) __PYX_ERR(0, 395, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_shuffled, Py_False) < 0) __PYX_ERR(0, 395, __pyx_L1_error) - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 395, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_sorted, Py_False) < 0) __PYX_ERR(0, 398, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_descending, Py_False) < 0) __PYX_ERR(0, 398, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_shuffled, Py_False) < 0) __PYX_ERR(0, 398, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 398, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "trade.pyx":396 + /* "trade.pyx":399 * """ * ret = (self.peak_buy_offers(good, sorted=False, descending=False, shuffled=False) + * self.peak_sell_offers(good, sorted=False, descending=False, shuffled=False)) # <<<<<<<<<<<<<< * if shuffled: * random.shuffle(ret) */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_peak_sell_offers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 396, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_peak_sell_offers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 399, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 396, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 399, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_good); __Pyx_GIVEREF(__pyx_v_good); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_good); - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 396, __pyx_L1_error) + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 399, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_sorted, Py_False) < 0) __PYX_ERR(0, 396, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_descending, Py_False) < 0) __PYX_ERR(0, 396, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_shuffled, Py_False) < 0) __PYX_ERR(0, 396, __pyx_L1_error) - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 396, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_sorted, Py_False) < 0) __PYX_ERR(0, 399, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_descending, Py_False) < 0) __PYX_ERR(0, 399, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_shuffled, Py_False) < 0) __PYX_ERR(0, 399, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 399, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":395 + /* "trade.pyx":398 * self.reject(offer) # optional * """ * ret = (self.peak_buy_offers(good, sorted=False, descending=False, shuffled=False) + # <<<<<<<<<<<<<< * self.peak_sell_offers(good, sorted=False, descending=False, shuffled=False)) * if shuffled: */ - __pyx_t_1 = PyNumber_Add(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 395, __pyx_L1_error) + __pyx_t_1 = PyNumber_Add(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 398, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_ret = __pyx_t_1; __pyx_t_1 = 0; - /* "trade.pyx":397 + /* "trade.pyx":400 * ret = (self.peak_buy_offers(good, sorted=False, descending=False, shuffled=False) + * self.peak_sell_offers(good, sorted=False, descending=False, shuffled=False)) * if shuffled: # <<<<<<<<<<<<<< * random.shuffle(ret) * if sorted: */ - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_shuffled); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 397, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_shuffled); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 400, __pyx_L1_error) if (__pyx_t_6) { - /* "trade.pyx":398 + /* "trade.pyx":401 * self.peak_sell_offers(good, sorted=False, descending=False, shuffled=False)) * if shuffled: * random.shuffle(ret) # <<<<<<<<<<<<<< * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 398, __pyx_L1_error) + __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 398, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; @@ -6350,13 +6358,13 @@ static PyObject *__pyx_pf_5trade_5Trade_16peak_offers(struct __pyx_obj_5trade_Tr } } if (!__pyx_t_5) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_ret); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 398, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_ret); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_ret}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 398, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); } else @@ -6364,19 +6372,19 @@ static PyObject *__pyx_pf_5trade_5Trade_16peak_offers(struct __pyx_obj_5trade_Tr #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_ret}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 398, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { - __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 398, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __pyx_t_5 = NULL; __Pyx_INCREF(__pyx_v_ret); __Pyx_GIVEREF(__pyx_v_ret); PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_ret); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 398, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } @@ -6384,7 +6392,7 @@ static PyObject *__pyx_pf_5trade_5Trade_16peak_offers(struct __pyx_obj_5trade_Tr __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":397 + /* "trade.pyx":400 * ret = (self.peak_buy_offers(good, sorted=False, descending=False, shuffled=False) + * self.peak_sell_offers(good, sorted=False, descending=False, shuffled=False)) * if shuffled: # <<<<<<<<<<<<<< @@ -6393,39 +6401,39 @@ static PyObject *__pyx_pf_5trade_5Trade_16peak_offers(struct __pyx_obj_5trade_Tr */ } - /* "trade.pyx":399 + /* "trade.pyx":402 * if shuffled: * random.shuffle(ret) * if sorted: # <<<<<<<<<<<<<< * ret.sort(key=lambda objects: objects.price, reverse=descending) * return ret */ - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_sorted); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 399, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_sorted); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 402, __pyx_L1_error) if (__pyx_t_6) { - /* "trade.pyx":400 + /* "trade.pyx":403 * random.shuffle(ret) * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) # <<<<<<<<<<<<<< * return ret * */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_ret, __pyx_n_s_sort); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 400, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_ret, __pyx_n_s_sort); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 400, __pyx_L1_error) + __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_11peak_offers_lambda5, 0, __pyx_n_s_peak_offers_locals_lambda, NULL, __pyx_n_s_trade, __pyx_d, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 400, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_11peak_offers_lambda5, 0, __pyx_n_s_peak_offers_locals_lambda, NULL, __pyx_n_s_trade, __pyx_d, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_key, __pyx_t_2) < 0) __PYX_ERR(0, 400, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_key, __pyx_t_2) < 0) __PYX_ERR(0, 403, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_reverse, __pyx_v_descending) < 0) __PYX_ERR(0, 400, __pyx_L1_error) - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 400, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_reverse, __pyx_v_descending) < 0) __PYX_ERR(0, 403, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":399 + /* "trade.pyx":402 * if shuffled: * random.shuffle(ret) * if sorted: # <<<<<<<<<<<<<< @@ -6434,7 +6442,7 @@ static PyObject *__pyx_pf_5trade_5Trade_16peak_offers(struct __pyx_obj_5trade_Tr */ } - /* "trade.pyx":401 + /* "trade.pyx":404 * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) * return ret # <<<<<<<<<<<<<< @@ -6446,7 +6454,7 @@ static PyObject *__pyx_pf_5trade_5Trade_16peak_offers(struct __pyx_obj_5trade_Tr __pyx_r = __pyx_v_ret; goto __pyx_L0; - /* "trade.pyx":370 + /* "trade.pyx":373 * return ret * * def peak_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< @@ -6470,7 +6478,7 @@ static PyObject *__pyx_pf_5trade_5Trade_16peak_offers(struct __pyx_obj_5trade_Tr return __pyx_r; } -/* "trade.pyx":403 +/* "trade.pyx":406 * return ret * * def sell(self, receiver, # <<<<<<<<<<<<<< @@ -6516,17 +6524,17 @@ static PyObject *__pyx_pw_5trade_5Trade_19sell(PyObject *__pyx_v_self, PyObject case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_good)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("sell", 0, 4, 6, 1); __PYX_ERR(0, 403, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("sell", 0, 4, 6, 1); __PYX_ERR(0, 406, __pyx_L3_error) } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_quantity)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("sell", 0, 4, 6, 2); __PYX_ERR(0, 403, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("sell", 0, 4, 6, 2); __PYX_ERR(0, 406, __pyx_L3_error) } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_price)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("sell", 0, 4, 6, 3); __PYX_ERR(0, 403, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("sell", 0, 4, 6, 3); __PYX_ERR(0, 406, __pyx_L3_error) } case 4: if (kw_args > 0) { @@ -6540,7 +6548,7 @@ static PyObject *__pyx_pw_5trade_5Trade_19sell(PyObject *__pyx_v_self, PyObject } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sell") < 0)) __PYX_ERR(0, 403, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sell") < 0)) __PYX_ERR(0, 406, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -6556,24 +6564,24 @@ static PyObject *__pyx_pw_5trade_5Trade_19sell(PyObject *__pyx_v_self, PyObject } __pyx_v_receiver = values[0]; __pyx_v_good = values[1]; - __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 404, __pyx_L3_error) - __pyx_v_price = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_price == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 404, __pyx_L3_error) + __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 407, __pyx_L3_error) + __pyx_v_price = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_price == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 407, __pyx_L3_error) __pyx_v_currency = ((PyObject*)values[4]); if (values[5]) { - __pyx_v_epsilon = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_epsilon == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 404, __pyx_L3_error) + __pyx_v_epsilon = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_epsilon == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 407, __pyx_L3_error) } else { __pyx_v_epsilon = __pyx_k_; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("sell", 0, 4, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 403, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("sell", 0, 4, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 406, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade.sell", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_currency), (&PyString_Type), 1, "currency", 1))) __PYX_ERR(0, 404, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_currency), (&PyString_Type), 1, "currency", 1))) __PYX_ERR(0, 407, __pyx_L1_error) __pyx_r = __pyx_pf_5trade_5Trade_18sell(((struct __pyx_obj_5trade_Trade *)__pyx_v_self), __pyx_v_receiver, __pyx_v_good, __pyx_v_quantity, __pyx_v_price, __pyx_v_currency, __pyx_v_epsilon); /* function exit code */ @@ -6604,7 +6612,7 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ PyObject *__pyx_t_11 = NULL; __Pyx_RefNannySetupContext("sell", 0); - /* "trade.pyx":454 + /* "trade.pyx":457 * """ * cdef double available * assert price > - epsilon, 'price %.30f is smaller than 0 - epsilon (%.30f)' % (price, - epsilon) # <<<<<<<<<<<<<< @@ -6614,11 +6622,11 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_price > (-__pyx_v_epsilon)) != 0))) { - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 454, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 454, __pyx_L1_error) + __pyx_t_2 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 454, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); @@ -6626,17 +6634,17 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_price_30f_is_smaller_than_0_epsi, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 454, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_price_30f_is_smaller_than_0_epsi, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 454, __pyx_L1_error) + __PYX_ERR(0, 457, __pyx_L1_error) } } #endif - /* "trade.pyx":455 + /* "trade.pyx":458 * cdef double available * assert price > - epsilon, 'price %.30f is smaller than 0 - epsilon (%.30f)' % (price, - epsilon) * if price < 0: # <<<<<<<<<<<<<< @@ -6646,7 +6654,7 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ __pyx_t_4 = ((__pyx_v_price < 0.0) != 0); if (__pyx_t_4) { - /* "trade.pyx":456 + /* "trade.pyx":459 * assert price > - epsilon, 'price %.30f is smaller than 0 - epsilon (%.30f)' % (price, - epsilon) * if price < 0: * price = 0 # <<<<<<<<<<<<<< @@ -6655,7 +6663,7 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ */ __pyx_v_price = 0.0; - /* "trade.pyx":455 + /* "trade.pyx":458 * cdef double available * assert price > - epsilon, 'price %.30f is smaller than 0 - epsilon (%.30f)' % (price, - epsilon) * if price < 0: # <<<<<<<<<<<<<< @@ -6664,25 +6672,25 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ */ } - /* "trade.pyx":459 + /* "trade.pyx":462 * # makes sure the quantity is between zero and maximum available, but * # if its only a little bit above or below its set to the bounds - * available = self._haves[good] # <<<<<<<<<<<<<< + * available = self._inventory[good] # <<<<<<<<<<<<<< * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 459, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 459, __pyx_L1_error) + __pyx_t_3 = PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 459, __pyx_L1_error) + __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 462, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_available = __pyx_t_5; - /* "trade.pyx":460 + /* "trade.pyx":463 * # if its only a little bit above or below its set to the bounds - * available = self._haves[good] + * available = self._inventory[good] * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) # <<<<<<<<<<<<<< * if quantity < 0: * quantity = 0 @@ -6690,11 +6698,11 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_quantity > (-__pyx_v_epsilon)) != 0))) { - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 460, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 463, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 460, __pyx_L1_error) + __pyx_t_2 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 463, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 460, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 463, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); @@ -6702,18 +6710,18 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2); __pyx_t_3 = 0; __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_quantity_30f_is_smaller_than_0_e, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 460, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_quantity_30f_is_smaller_than_0_e, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 463, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 460, __pyx_L1_error) + __PYX_ERR(0, 463, __pyx_L1_error) } } #endif - /* "trade.pyx":461 - * available = self._haves[good] + /* "trade.pyx":464 + * available = self._inventory[good] * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: # <<<<<<<<<<<<<< * quantity = 0 @@ -6722,7 +6730,7 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ __pyx_t_4 = ((__pyx_v_quantity < 0.0) != 0); if (__pyx_t_4) { - /* "trade.pyx":462 + /* "trade.pyx":465 * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: * quantity = 0 # <<<<<<<<<<<<<< @@ -6731,8 +6739,8 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ */ __pyx_v_quantity = 0.0; - /* "trade.pyx":461 - * available = self._haves[good] + /* "trade.pyx":464 + * available = self._inventory[good] * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: # <<<<<<<<<<<<<< * quantity = 0 @@ -6740,7 +6748,7 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ */ } - /* "trade.pyx":463 + /* "trade.pyx":466 * if quantity < 0: * quantity = 0 * if quantity > available + epsilon + epsilon * fmax(quantity, available): # <<<<<<<<<<<<<< @@ -6750,18 +6758,18 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ __pyx_t_4 = ((__pyx_v_quantity > ((__pyx_v_available + __pyx_v_epsilon) + (__pyx_v_epsilon * __pyx_f_5trade_fmax(__pyx_v_quantity, __pyx_v_available)))) != 0); if (__pyx_t_4) { - /* "trade.pyx":464 + /* "trade.pyx":467 * quantity = 0 * if quantity > available + epsilon + epsilon * fmax(quantity, available): * raise NotEnoughGoods(self.name, good, quantity - available) # <<<<<<<<<<<<<< * if quantity > available: * quantity = available */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NotEnoughGoods); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 464, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NotEnoughGoods); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 464, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = PyFloat_FromDouble((__pyx_v_quantity - __pyx_v_available)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 464, __pyx_L1_error) + __pyx_t_6 = PyFloat_FromDouble((__pyx_v_quantity - __pyx_v_available)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_8 = 0; @@ -6778,7 +6786,7 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_3, __pyx_v_good, __pyx_t_6}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 464, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 467, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -6788,7 +6796,7 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_3, __pyx_v_good, __pyx_t_6}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 464, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 467, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -6796,7 +6804,7 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ } else #endif { - __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 464, __pyx_L1_error) + __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; @@ -6810,16 +6818,16 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_6); __pyx_t_3 = 0; __pyx_t_6 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 464, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 464, __pyx_L1_error) + __PYX_ERR(0, 467, __pyx_L1_error) - /* "trade.pyx":463 + /* "trade.pyx":466 * if quantity < 0: * quantity = 0 * if quantity > available + epsilon + epsilon * fmax(quantity, available): # <<<<<<<<<<<<<< @@ -6828,7 +6836,7 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ */ } - /* "trade.pyx":465 + /* "trade.pyx":468 * if quantity > available + epsilon + epsilon * fmax(quantity, available): * raise NotEnoughGoods(self.name, good, quantity - available) * if quantity > available: # <<<<<<<<<<<<<< @@ -6838,7 +6846,7 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ __pyx_t_4 = ((__pyx_v_quantity > __pyx_v_available) != 0); if (__pyx_t_4) { - /* "trade.pyx":466 + /* "trade.pyx":469 * raise NotEnoughGoods(self.name, good, quantity - available) * if quantity > available: * quantity = available # <<<<<<<<<<<<<< @@ -6847,7 +6855,7 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ */ __pyx_v_quantity = __pyx_v_available; - /* "trade.pyx":465 + /* "trade.pyx":468 * if quantity > available + epsilon + epsilon * fmax(quantity, available): * raise NotEnoughGoods(self.name, good, quantity - available) * if quantity > available: # <<<<<<<<<<<<<< @@ -6856,14 +6864,14 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ */ } - /* "trade.pyx":468 + /* "trade.pyx":471 * quantity = available * * offer_id = self._offer_counter() # <<<<<<<<<<<<<< - * self._haves[good] -= quantity + * self._inventory.reserve(good, quantity) * cdef Offer offer = Offer(self.group, */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_offer_counter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 468, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_offer_counter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { @@ -6876,132 +6884,171 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ } } if (__pyx_t_9) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 468, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 471, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 468, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 471, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_offer_id = __pyx_t_2; __pyx_t_2 = 0; - /* "trade.pyx":469 + /* "trade.pyx":472 * * offer_id = self._offer_counter() - * self._haves[good] -= quantity # <<<<<<<<<<<<<< + * self._inventory.reserve(good, quantity) # <<<<<<<<<<<<<< * cdef Offer offer = Offer(self.group, * self.id, */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 469, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_v_good); - __pyx_t_1 = __pyx_v_good; - __pyx_t_9 = PyObject_GetItem(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 469, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 472, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_reserve); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 472, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 469, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_3 = PyNumber_InPlaceSubtract(__pyx_t_9, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 469, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_2, __pyx_t_1, __pyx_t_3) < 0)) __PYX_ERR(0, 469, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 472, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = NULL; + __pyx_t_8 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_9); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_9, function); + __pyx_t_8 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_9)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_good, __pyx_t_1}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 472, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_good, __pyx_t_1}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 472, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + { + __pyx_t_3 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 472, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (__pyx_t_6) { + __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = NULL; + } + __Pyx_INCREF(__pyx_v_good); + __Pyx_GIVEREF(__pyx_v_good); + PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_8, __pyx_v_good); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_8, __pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 472, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":470 + /* "trade.pyx":473 * offer_id = self._offer_counter() - * self._haves[good] -= quantity + * self._inventory.reserve(good, quantity) * cdef Offer offer = Offer(self.group, # <<<<<<<<<<<<<< * self.id, * receiver[0], */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_group); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 470, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_group); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - /* "trade.pyx":471 - * self._haves[good] -= quantity + /* "trade.pyx":474 + * self._inventory.reserve(good, quantity) * cdef Offer offer = Offer(self.group, * self.id, # <<<<<<<<<<<<<< * receiver[0], * receiver[1], */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 471, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_id); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 474, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); - /* "trade.pyx":472 + /* "trade.pyx":475 * cdef Offer offer = Offer(self.group, * self.id, * receiver[0], # <<<<<<<<<<<<<< * receiver[1], * good, */ - __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_receiver, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 472, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_receiver, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 475, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - /* "trade.pyx":473 + /* "trade.pyx":476 * self.id, * receiver[0], * receiver[1], # <<<<<<<<<<<<<< * good, * quantity, */ - __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_receiver, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 473, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_receiver, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 476, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); - /* "trade.pyx":475 + /* "trade.pyx":478 * receiver[1], * good, * quantity, # <<<<<<<<<<<<<< * price, * currency, */ - __pyx_t_9 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 475, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 478, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); - /* "trade.pyx":476 + /* "trade.pyx":479 * good, * quantity, * price, # <<<<<<<<<<<<<< * currency, * True, */ - __pyx_t_7 = PyFloat_FromDouble(__pyx_v_price); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 476, __pyx_L1_error) + __pyx_t_7 = PyFloat_FromDouble(__pyx_v_price); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 479, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - /* "trade.pyx":482 + /* "trade.pyx":485 * -2, * offer_id, * self.round, # <<<<<<<<<<<<<< * -2) * self.given_offers[offer_id] = offer */ - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_round); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 482, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_round); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 485, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - /* "trade.pyx":470 + /* "trade.pyx":473 * offer_id = self._offer_counter() - * self._haves[good] -= quantity + * self._inventory.reserve(good, quantity) * cdef Offer offer = Offer(self.group, # <<<<<<<<<<<<<< * self.id, * receiver[0], */ - __pyx_t_11 = PyTuple_New(14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 470, __pyx_L1_error) + __pyx_t_11 = PyTuple_New(14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_11, 3, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_11, 3, __pyx_t_1); __Pyx_INCREF(__pyx_v_good); __Pyx_GIVEREF(__pyx_v_good); PyTuple_SET_ITEM(__pyx_t_11, 4, __pyx_v_good); - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_11, 5, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_11, 5, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_11, 6, __pyx_t_7); __Pyx_INCREF(__pyx_v_currency); @@ -7025,50 +7072,50 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ __Pyx_GIVEREF(__pyx_int_neg_2); PyTuple_SET_ITEM(__pyx_t_11, 13, __pyx_int_neg_2); __pyx_t_2 = 0; - __pyx_t_1 = 0; + __pyx_t_9 = 0; __pyx_t_3 = 0; + __pyx_t_1 = 0; __pyx_t_6 = 0; - __pyx_t_9 = 0; __pyx_t_7 = 0; __pyx_t_10 = 0; - __pyx_t_10 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5trade_Offer), __pyx_t_11, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 470, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5trade_Offer), __pyx_t_11, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_v_offer = ((struct __pyx_obj_5trade_Offer *)__pyx_t_10); __pyx_t_10 = 0; - /* "trade.pyx":484 + /* "trade.pyx":487 * self.round, * -2) * self.given_offers[offer_id] = offer # <<<<<<<<<<<<<< * self._send(receiver[0], receiver[1], '!s', offer) * return offer */ - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_given_offers); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 484, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_given_offers); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 487, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - if (unlikely(PyObject_SetItem(__pyx_t_10, __pyx_v_offer_id, ((PyObject *)__pyx_v_offer)) < 0)) __PYX_ERR(0, 484, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_10, __pyx_v_offer_id, ((PyObject *)__pyx_v_offer)) < 0)) __PYX_ERR(0, 487, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - /* "trade.pyx":485 + /* "trade.pyx":488 * -2) * self.given_offers[offer_id] = offer * self._send(receiver[0], receiver[1], '!s', offer) # <<<<<<<<<<<<<< * return offer * */ - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 485, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 488, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_receiver, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 485, __pyx_L1_error) + __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_receiver, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 488, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_receiver, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 485, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_6 = NULL; + __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_receiver, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 488, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_1 = NULL; __pyx_t_8 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_11); - if (likely(__pyx_t_6)) { + __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11); + if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); - __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_8 = 1; @@ -7076,34 +7123,34 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_11)) { - PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_t_7, __pyx_t_9, __pyx_kp_s_s, ((PyObject *)__pyx_v_offer)}; - __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 485, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + PyObject *__pyx_temp[5] = {__pyx_t_1, __pyx_t_7, __pyx_t_6, __pyx_kp_s_s, ((PyObject *)__pyx_v_offer)}; + __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 488, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { - PyObject *__pyx_temp[5] = {__pyx_t_6, __pyx_t_7, __pyx_t_9, __pyx_kp_s_s, ((PyObject *)__pyx_v_offer)}; - __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 485, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + PyObject *__pyx_temp[5] = {__pyx_t_1, __pyx_t_7, __pyx_t_6, __pyx_kp_s_s, ((PyObject *)__pyx_v_offer)}; + __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 488, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { - __pyx_t_3 = PyTuple_New(4+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 485, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(4+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 488, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (__pyx_t_6) { - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = NULL; + if (__pyx_t_1) { + __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = NULL; } __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_8, __pyx_t_7); - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_8, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_8, __pyx_t_6); __Pyx_INCREF(__pyx_kp_s_s); __Pyx_GIVEREF(__pyx_kp_s_s); PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_8, __pyx_kp_s_s); @@ -7111,15 +7158,15 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ __Pyx_GIVEREF(((PyObject *)__pyx_v_offer)); PyTuple_SET_ITEM(__pyx_t_3, 3+__pyx_t_8, ((PyObject *)__pyx_v_offer)); __pyx_t_7 = 0; - __pyx_t_9 = 0; - __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_3, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 485, __pyx_L1_error) + __pyx_t_6 = 0; + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_3, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 488, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - /* "trade.pyx":486 + /* "trade.pyx":489 * self.given_offers[offer_id] = offer * self._send(receiver[0], receiver[1], '!s', offer) * return offer # <<<<<<<<<<<<<< @@ -7131,7 +7178,7 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ __pyx_r = ((PyObject *)__pyx_v_offer); goto __pyx_L0; - /* "trade.pyx":403 + /* "trade.pyx":406 * return ret * * def sell(self, receiver, # <<<<<<<<<<<<<< @@ -7159,7 +7206,7 @@ static PyObject *__pyx_pf_5trade_5Trade_18sell(struct __pyx_obj_5trade_Trade *__ return __pyx_r; } -/* "trade.pyx":488 +/* "trade.pyx":491 * return offer * * def buy(self, receiver, good, # <<<<<<<<<<<<<< @@ -7205,17 +7252,17 @@ static PyObject *__pyx_pw_5trade_5Trade_21buy(PyObject *__pyx_v_self, PyObject * case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_good)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("buy", 0, 4, 6, 1); __PYX_ERR(0, 488, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("buy", 0, 4, 6, 1); __PYX_ERR(0, 491, __pyx_L3_error) } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_quantity)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("buy", 0, 4, 6, 2); __PYX_ERR(0, 488, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("buy", 0, 4, 6, 2); __PYX_ERR(0, 491, __pyx_L3_error) } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_price)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("buy", 0, 4, 6, 3); __PYX_ERR(0, 488, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("buy", 0, 4, 6, 3); __PYX_ERR(0, 491, __pyx_L3_error) } case 4: if (kw_args > 0) { @@ -7229,7 +7276,7 @@ static PyObject *__pyx_pw_5trade_5Trade_21buy(PyObject *__pyx_v_self, PyObject * } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "buy") < 0)) __PYX_ERR(0, 488, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "buy") < 0)) __PYX_ERR(0, 491, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -7245,24 +7292,24 @@ static PyObject *__pyx_pw_5trade_5Trade_21buy(PyObject *__pyx_v_self, PyObject * } __pyx_v_receiver = values[0]; __pyx_v_good = values[1]; - __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 489, __pyx_L3_error) - __pyx_v_price = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_price == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 489, __pyx_L3_error) + __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 492, __pyx_L3_error) + __pyx_v_price = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_price == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 492, __pyx_L3_error) __pyx_v_currency = ((PyObject*)values[4]); if (values[5]) { - __pyx_v_epsilon = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_epsilon == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 489, __pyx_L3_error) + __pyx_v_epsilon = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_epsilon == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 492, __pyx_L3_error) } else { __pyx_v_epsilon = __pyx_k__2; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("buy", 0, 4, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 488, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("buy", 0, 4, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 491, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade.buy", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_currency), (&PyString_Type), 1, "currency", 1))) __PYX_ERR(0, 489, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_currency), (&PyString_Type), 1, "currency", 1))) __PYX_ERR(0, 492, __pyx_L1_error) __pyx_r = __pyx_pf_5trade_5Trade_20buy(((struct __pyx_obj_5trade_Trade *)__pyx_v_self), __pyx_v_receiver, __pyx_v_good, __pyx_v_quantity, __pyx_v_price, __pyx_v_currency, __pyx_v_epsilon); /* function exit code */ @@ -7287,15 +7334,14 @@ static PyObject *__pyx_pf_5trade_5Trade_20buy(struct __pyx_obj_5trade_Trade *__p int __pyx_t_4; double __pyx_t_5; PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - int __pyx_t_8; + int __pyx_t_7; + PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; - PyObject *__pyx_t_12 = NULL; __Pyx_RefNannySetupContext("buy", 0); - /* "trade.pyx":521 + /* "trade.pyx":524 * cdef double available * cdef double money_amount * assert price > - epsilon, 'price %.30f is smaller than 0 - epsilon (%.30f)' % (price, - epsilon) # <<<<<<<<<<<<<< @@ -7305,11 +7351,11 @@ static PyObject *__pyx_pf_5trade_5Trade_20buy(struct __pyx_obj_5trade_Trade *__p #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_price > (-__pyx_v_epsilon)) != 0))) { - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 521, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 524, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 521, __pyx_L1_error) + __pyx_t_2 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 524, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 521, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 524, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); @@ -7317,17 +7363,17 @@ static PyObject *__pyx_pf_5trade_5Trade_20buy(struct __pyx_obj_5trade_Trade *__p PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_price_30f_is_smaller_than_0_epsi, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 521, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_price_30f_is_smaller_than_0_epsi, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 524, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 521, __pyx_L1_error) + __PYX_ERR(0, 524, __pyx_L1_error) } } #endif - /* "trade.pyx":522 + /* "trade.pyx":525 * cdef double money_amount * assert price > - epsilon, 'price %.30f is smaller than 0 - epsilon (%.30f)' % (price, - epsilon) * if price < 0: # <<<<<<<<<<<<<< @@ -7337,7 +7383,7 @@ static PyObject *__pyx_pf_5trade_5Trade_20buy(struct __pyx_obj_5trade_Trade *__p __pyx_t_4 = ((__pyx_v_price < 0.0) != 0); if (__pyx_t_4) { - /* "trade.pyx":523 + /* "trade.pyx":526 * assert price > - epsilon, 'price %.30f is smaller than 0 - epsilon (%.30f)' % (price, - epsilon) * if price < 0: * price = 0 # <<<<<<<<<<<<<< @@ -7346,7 +7392,7 @@ static PyObject *__pyx_pf_5trade_5Trade_20buy(struct __pyx_obj_5trade_Trade *__p */ __pyx_v_price = 0.0; - /* "trade.pyx":522 + /* "trade.pyx":525 * cdef double money_amount * assert price > - epsilon, 'price %.30f is smaller than 0 - epsilon (%.30f)' % (price, - epsilon) * if price < 0: # <<<<<<<<<<<<<< @@ -7355,7 +7401,7 @@ static PyObject *__pyx_pf_5trade_5Trade_20buy(struct __pyx_obj_5trade_Trade *__p */ } - /* "trade.pyx":524 + /* "trade.pyx":527 * if price < 0: * price = 0 * money_amount = quantity * price # <<<<<<<<<<<<<< @@ -7364,25 +7410,25 @@ static PyObject *__pyx_pf_5trade_5Trade_20buy(struct __pyx_obj_5trade_Trade *__p */ __pyx_v_money_amount = (__pyx_v_quantity * __pyx_v_price); - /* "trade.pyx":527 + /* "trade.pyx":530 * # makes sure the money_amount is between zero and maximum available, but * # if its only a little bit above or below its set to the bounds - * available = self._haves[currency] # <<<<<<<<<<<<<< + * available = self._inventory[currency] # <<<<<<<<<<<<<< * assert money_amount > - epsilon, '%s (price * quantity) %.30f is smaller than 0 - epsilon (%.30f)' % (currency, money_amount, - epsilon) * if money_amount < 0: */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 527, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 530, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_GetItem(__pyx_t_2, __pyx_v_currency); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 527, __pyx_L1_error) + __pyx_t_3 = PyObject_GetItem(__pyx_t_2, __pyx_v_currency); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 530, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 527, __pyx_L1_error) + __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 530, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_available = __pyx_t_5; - /* "trade.pyx":528 + /* "trade.pyx":531 * # if its only a little bit above or below its set to the bounds - * available = self._haves[currency] + * available = self._inventory[currency] * assert money_amount > - epsilon, '%s (price * quantity) %.30f is smaller than 0 - epsilon (%.30f)' % (currency, money_amount, - epsilon) # <<<<<<<<<<<<<< * if money_amount < 0: * money_amount = 0 @@ -7390,11 +7436,11 @@ static PyObject *__pyx_pf_5trade_5Trade_20buy(struct __pyx_obj_5trade_Trade *__p #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_money_amount > (-__pyx_v_epsilon)) != 0))) { - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_money_amount); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 528, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_money_amount); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 531, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 528, __pyx_L1_error) + __pyx_t_2 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 531, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 528, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 531, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_currency); __Pyx_GIVEREF(__pyx_v_currency); @@ -7405,135 +7451,47 @@ static PyObject *__pyx_pf_5trade_5Trade_20buy(struct __pyx_obj_5trade_Trade *__p PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_2); __pyx_t_3 = 0; __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_s_price_quantity_30f_is_smaller, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 528, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_s_price_quantity_30f_is_smaller, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 531, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 528, __pyx_L1_error) + __PYX_ERR(0, 531, __pyx_L1_error) } } #endif - /* "trade.pyx":529 - * available = self._haves[currency] + /* "trade.pyx":532 + * available = self._inventory[currency] * assert money_amount > - epsilon, '%s (price * quantity) %.30f is smaller than 0 - epsilon (%.30f)' % (currency, money_amount, - epsilon) * if money_amount < 0: # <<<<<<<<<<<<<< * money_amount = 0 - * if money_amount > available + epsilon + epsilon * fmax(money_amount, available): + * if money_amount > available: */ __pyx_t_4 = ((__pyx_v_money_amount < 0.0) != 0); if (__pyx_t_4) { - /* "trade.pyx":530 + /* "trade.pyx":533 * assert money_amount > - epsilon, '%s (price * quantity) %.30f is smaller than 0 - epsilon (%.30f)' % (currency, money_amount, - epsilon) * if money_amount < 0: * money_amount = 0 # <<<<<<<<<<<<<< - * if money_amount > available + epsilon + epsilon * fmax(money_amount, available): - * raise NotEnoughGoods(self.name, currency, money_amount - available) + * if money_amount > available: + * money_amount = available */ __pyx_v_money_amount = 0.0; - /* "trade.pyx":529 - * available = self._haves[currency] + /* "trade.pyx":532 + * available = self._inventory[currency] * assert money_amount > - epsilon, '%s (price * quantity) %.30f is smaller than 0 - epsilon (%.30f)' % (currency, money_amount, - epsilon) * if money_amount < 0: # <<<<<<<<<<<<<< * money_amount = 0 - * if money_amount > available + epsilon + epsilon * fmax(money_amount, available): - */ - } - - /* "trade.pyx":531 - * if money_amount < 0: - * money_amount = 0 - * if money_amount > available + epsilon + epsilon * fmax(money_amount, available): # <<<<<<<<<<<<<< - * raise NotEnoughGoods(self.name, currency, money_amount - available) - * if money_amount > available: - */ - __pyx_t_4 = ((__pyx_v_money_amount > ((__pyx_v_available + __pyx_v_epsilon) + (__pyx_v_epsilon * __pyx_f_5trade_fmax(__pyx_v_money_amount, __pyx_v_available)))) != 0); - if (__pyx_t_4) { - - /* "trade.pyx":532 - * money_amount = 0 - * if money_amount > available + epsilon + epsilon * fmax(money_amount, available): - * raise NotEnoughGoods(self.name, currency, money_amount - available) # <<<<<<<<<<<<<< * if money_amount > available: - * money_amount = available */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NotEnoughGoods); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 532, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 532, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = PyFloat_FromDouble((__pyx_v_money_amount - __pyx_v_available)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 532, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = NULL; - __pyx_t_8 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_7)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_7); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - __pyx_t_8 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_3, __pyx_v_currency, __pyx_t_6}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 532, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_3, __pyx_v_currency, __pyx_t_6}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 532, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - { - __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 532, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - if (__pyx_t_7) { - __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; - } - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_3); - __Pyx_INCREF(__pyx_v_currency); - __Pyx_GIVEREF(__pyx_v_currency); - PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_currency); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_6); - __pyx_t_3 = 0; - __pyx_t_6 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 532, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 532, __pyx_L1_error) + } - /* "trade.pyx":531 + /* "trade.pyx":534 * if money_amount < 0: * money_amount = 0 - * if money_amount > available + epsilon + epsilon * fmax(money_amount, available): # <<<<<<<<<<<<<< - * raise NotEnoughGoods(self.name, currency, money_amount - available) - * if money_amount > available: - */ - } - - /* "trade.pyx":533 - * if money_amount > available + epsilon + epsilon * fmax(money_amount, available): - * raise NotEnoughGoods(self.name, currency, money_amount - available) * if money_amount > available: # <<<<<<<<<<<<<< * money_amount = available * @@ -7541,8 +7499,8 @@ static PyObject *__pyx_pf_5trade_5Trade_20buy(struct __pyx_obj_5trade_Trade *__p __pyx_t_4 = ((__pyx_v_money_amount > __pyx_v_available) != 0); if (__pyx_t_4) { - /* "trade.pyx":534 - * raise NotEnoughGoods(self.name, currency, money_amount - available) + /* "trade.pyx":535 + * money_amount = 0 * if money_amount > available: * money_amount = available # <<<<<<<<<<<<<< * @@ -7550,279 +7508,318 @@ static PyObject *__pyx_pf_5trade_5Trade_20buy(struct __pyx_obj_5trade_Trade *__p */ __pyx_v_money_amount = __pyx_v_available; - /* "trade.pyx":533 - * if money_amount > available + epsilon + epsilon * fmax(money_amount, available): - * raise NotEnoughGoods(self.name, currency, money_amount - available) + /* "trade.pyx":534 + * if money_amount < 0: + * money_amount = 0 * if money_amount > available: # <<<<<<<<<<<<<< * money_amount = available * */ } - /* "trade.pyx":536 + /* "trade.pyx":537 * money_amount = available * * offer_id = self._offer_counter() # <<<<<<<<<<<<<< - * self._haves[currency] -= money_amount + * self._inventory.reserve(currency, money_amount) * cdef Offer offer = Offer(self.group, */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_offer_counter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 536, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_offer_counter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 537, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = NULL; + __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_9)) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } - if (__pyx_t_9) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 536, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if (__pyx_t_3) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 537, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 536, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 537, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_offer_id = __pyx_t_2; __pyx_t_2 = 0; - /* "trade.pyx":537 + /* "trade.pyx":538 * * offer_id = self._offer_counter() - * self._haves[currency] -= money_amount # <<<<<<<<<<<<<< + * self._inventory.reserve(currency, money_amount) # <<<<<<<<<<<<<< * cdef Offer offer = Offer(self.group, * self.id, */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 537, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_v_currency); - __pyx_t_10 = __pyx_v_currency; - __pyx_t_1 = PyObject_GetItem(__pyx_t_2, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 537, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 538, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = PyFloat_FromDouble(__pyx_v_money_amount); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 537, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_6 = PyNumber_InPlaceSubtract(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 537, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_reserve); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 538, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_2, __pyx_t_10, __pyx_t_6) < 0)) __PYX_ERR(0, 537, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_money_amount); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 538, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = NULL; + __pyx_t_7 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + __pyx_t_7 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_currency, __pyx_t_1}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 538, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_currency, __pyx_t_1}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 538, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + { + __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 538, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + if (__pyx_t_6) { + __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; + } + __Pyx_INCREF(__pyx_v_currency); + __Pyx_GIVEREF(__pyx_v_currency); + PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_currency); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 538, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":538 + /* "trade.pyx":539 * offer_id = self._offer_counter() - * self._haves[currency] -= money_amount + * self._inventory.reserve(currency, money_amount) * cdef Offer offer = Offer(self.group, # <<<<<<<<<<<<<< * self.id, * receiver[0], */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_group); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 538, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_group); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 539, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - /* "trade.pyx":539 - * self._haves[currency] -= money_amount + /* "trade.pyx":540 + * self._inventory.reserve(currency, money_amount) * cdef Offer offer = Offer(self.group, * self.id, # <<<<<<<<<<<<<< * receiver[0], * receiver[1], */ - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 539, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 540, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); - /* "trade.pyx":540 + /* "trade.pyx":541 * cdef Offer offer = Offer(self.group, * self.id, * receiver[0], # <<<<<<<<<<<<<< * receiver[1], * good, */ - __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_receiver, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 540, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); + __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_receiver, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 541, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); - /* "trade.pyx":541 + /* "trade.pyx":542 * self.id, * receiver[0], * receiver[1], # <<<<<<<<<<<<<< * good, * quantity, */ - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_receiver, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 541, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_receiver, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 542, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - /* "trade.pyx":543 + /* "trade.pyx":544 * receiver[1], * good, * quantity, # <<<<<<<<<<<<<< * price, * currency, */ - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 543, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 544, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); - /* "trade.pyx":544 + /* "trade.pyx":545 * good, * quantity, * price, # <<<<<<<<<<<<<< * currency, * False, */ - __pyx_t_7 = PyFloat_FromDouble(__pyx_v_price); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 544, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); + __pyx_t_9 = PyFloat_FromDouble(__pyx_v_price); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 545, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); - /* "trade.pyx":550 + /* "trade.pyx":551 * -1, * offer_id, * self.round, # <<<<<<<<<<<<<< * -1) * self._send(receiver[0], receiver[1], '!b', offer) */ - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_round); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 550, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_round); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 551, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); - /* "trade.pyx":538 + /* "trade.pyx":539 * offer_id = self._offer_counter() - * self._haves[currency] -= money_amount + * self._inventory.reserve(currency, money_amount) * cdef Offer offer = Offer(self.group, # <<<<<<<<<<<<<< * self.id, * receiver[0], */ - __pyx_t_12 = PyTuple_New(14); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 538, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); + __pyx_t_11 = PyTuple_New(14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 539, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_6); - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_12, 3, __pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_11, 3, __pyx_t_1); __Pyx_INCREF(__pyx_v_good); __Pyx_GIVEREF(__pyx_v_good); - PyTuple_SET_ITEM(__pyx_t_12, 4, __pyx_v_good); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_12, 5, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_12, 6, __pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_11, 4, __pyx_v_good); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_11, 5, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_11, 6, __pyx_t_9); __Pyx_INCREF(__pyx_v_currency); __Pyx_GIVEREF(__pyx_v_currency); - PyTuple_SET_ITEM(__pyx_t_12, 7, __pyx_v_currency); + PyTuple_SET_ITEM(__pyx_t_11, 7, __pyx_v_currency); __Pyx_INCREF(Py_False); __Pyx_GIVEREF(Py_False); - PyTuple_SET_ITEM(__pyx_t_12, 8, Py_False); + PyTuple_SET_ITEM(__pyx_t_11, 8, Py_False); __Pyx_INCREF(__pyx_n_s_new); __Pyx_GIVEREF(__pyx_n_s_new); - PyTuple_SET_ITEM(__pyx_t_12, 9, __pyx_n_s_new); + PyTuple_SET_ITEM(__pyx_t_11, 9, __pyx_n_s_new); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); - PyTuple_SET_ITEM(__pyx_t_12, 10, __pyx_int_neg_1); + PyTuple_SET_ITEM(__pyx_t_11, 10, __pyx_int_neg_1); __Pyx_INCREF(__pyx_v_offer_id); __Pyx_GIVEREF(__pyx_v_offer_id); - PyTuple_SET_ITEM(__pyx_t_12, 11, __pyx_v_offer_id); - __Pyx_GIVEREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_12, 12, __pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_11, 11, __pyx_v_offer_id); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_11, 12, __pyx_t_10); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); - PyTuple_SET_ITEM(__pyx_t_12, 13, __pyx_int_neg_1); + PyTuple_SET_ITEM(__pyx_t_11, 13, __pyx_int_neg_1); __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_t_8 = 0; + __pyx_t_1 = 0; __pyx_t_6 = 0; __pyx_t_9 = 0; - __pyx_t_1 = 0; - __pyx_t_3 = 0; - __pyx_t_7 = 0; - __pyx_t_11 = 0; - __pyx_t_11 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5trade_Offer), __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 538, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __pyx_v_offer = ((struct __pyx_obj_5trade_Offer *)__pyx_t_11); - __pyx_t_11 = 0; + __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5trade_Offer), __pyx_t_11, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 539, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_v_offer = ((struct __pyx_obj_5trade_Offer *)__pyx_t_10); + __pyx_t_10 = 0; - /* "trade.pyx":552 + /* "trade.pyx":553 * self.round, * -1) * self._send(receiver[0], receiver[1], '!b', offer) # <<<<<<<<<<<<<< * self.given_offers[offer_id] = offer * return offer */ - __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 552, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_receiver, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 552, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_receiver, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 552, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 553, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_receiver, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 553, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_receiver, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 553, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = NULL; - __pyx_t_8 = 0; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) { - __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_12); + __pyx_t_7 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) { + __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_1)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_12, function); - __pyx_t_8 = 1; + __Pyx_DECREF_SET(__pyx_t_11, function); + __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_12)) { - PyObject *__pyx_temp[5] = {__pyx_t_1, __pyx_t_7, __pyx_t_3, __pyx_kp_s_b, ((PyObject *)__pyx_v_offer)}; - __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 552, __pyx_L1_error) + if (PyFunction_Check(__pyx_t_11)) { + PyObject *__pyx_temp[5] = {__pyx_t_1, __pyx_t_9, __pyx_t_6, __pyx_kp_s_b, ((PyObject *)__pyx_v_offer)}; + __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 553, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { - PyObject *__pyx_temp[5] = {__pyx_t_1, __pyx_t_7, __pyx_t_3, __pyx_kp_s_b, ((PyObject *)__pyx_v_offer)}; - __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_8, 4+__pyx_t_8); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 552, __pyx_L1_error) + if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { + PyObject *__pyx_temp[5] = {__pyx_t_1, __pyx_t_9, __pyx_t_6, __pyx_kp_s_b, ((PyObject *)__pyx_v_offer)}; + __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_7, 4+__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 553, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { - __pyx_t_9 = PyTuple_New(4+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 552, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); + __pyx_t_8 = PyTuple_New(4+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 553, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_1) { - __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1); __pyx_t_1 = NULL; + __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); __pyx_t_1 = NULL; } - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_7); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_6); __Pyx_INCREF(__pyx_kp_s_b); __Pyx_GIVEREF(__pyx_kp_s_b); - PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_kp_s_b); + PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_kp_s_b); __Pyx_INCREF(((PyObject *)__pyx_v_offer)); __Pyx_GIVEREF(((PyObject *)__pyx_v_offer)); - PyTuple_SET_ITEM(__pyx_t_9, 3+__pyx_t_8, ((PyObject *)__pyx_v_offer)); - __pyx_t_7 = 0; - __pyx_t_3 = 0; - __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_9, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 552, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + PyTuple_SET_ITEM(__pyx_t_8, 3+__pyx_t_7, ((PyObject *)__pyx_v_offer)); + __pyx_t_9 = 0; + __pyx_t_6 = 0; + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_8, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 553, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - /* "trade.pyx":553 + /* "trade.pyx":554 * -1) * self._send(receiver[0], receiver[1], '!b', offer) * self.given_offers[offer_id] = offer # <<<<<<<<<<<<<< * return offer * */ - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_given_offers); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 553, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - if (unlikely(PyObject_SetItem(__pyx_t_11, __pyx_v_offer_id, ((PyObject *)__pyx_v_offer)) < 0)) __PYX_ERR(0, 553, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_given_offers); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 554, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + if (unlikely(PyObject_SetItem(__pyx_t_10, __pyx_v_offer_id, ((PyObject *)__pyx_v_offer)) < 0)) __PYX_ERR(0, 554, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - /* "trade.pyx":554 + /* "trade.pyx":555 * self._send(receiver[0], receiver[1], '!b', offer) * self.given_offers[offer_id] = offer * return offer # <<<<<<<<<<<<<< @@ -7834,7 +7831,7 @@ static PyObject *__pyx_pf_5trade_5Trade_20buy(struct __pyx_obj_5trade_Trade *__p __pyx_r = ((PyObject *)__pyx_v_offer); goto __pyx_L0; - /* "trade.pyx":488 + /* "trade.pyx":491 * return offer * * def buy(self, receiver, good, # <<<<<<<<<<<<<< @@ -7848,11 +7845,10 @@ static PyObject *__pyx_pf_5trade_5Trade_20buy(struct __pyx_obj_5trade_Trade *__p __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); - __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("trade.Trade.buy", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -7863,7 +7859,7 @@ static PyObject *__pyx_pf_5trade_5Trade_20buy(struct __pyx_obj_5trade_Trade *__p return __pyx_r; } -/* "trade.pyx":556 +/* "trade.pyx":557 * return offer * * def accept(self, Offer offer, double quantity=-999, double epsilon=epsilon): # <<<<<<<<<<<<<< @@ -7911,7 +7907,7 @@ static PyObject *__pyx_pw_5trade_5Trade_23accept(PyObject *__pyx_v_self, PyObjec } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "accept") < 0)) __PYX_ERR(0, 556, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "accept") < 0)) __PYX_ERR(0, 557, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -7924,25 +7920,25 @@ static PyObject *__pyx_pw_5trade_5Trade_23accept(PyObject *__pyx_v_self, PyObjec } __pyx_v_offer = ((struct __pyx_obj_5trade_Offer *)values[0]); if (values[1]) { - __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 556, __pyx_L3_error) + __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 557, __pyx_L3_error) } else { __pyx_v_quantity = ((double)-999.0); } if (values[2]) { - __pyx_v_epsilon = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_epsilon == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 556, __pyx_L3_error) + __pyx_v_epsilon = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_epsilon == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 557, __pyx_L3_error) } else { __pyx_v_epsilon = __pyx_k__3; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("accept", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 556, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("accept", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 557, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade.accept", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_offer), __pyx_ptype_5trade_Offer, 1, "offer", 0))) __PYX_ERR(0, 556, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_offer), __pyx_ptype_5trade_Offer, 1, "offer", 0))) __PYX_ERR(0, 557, __pyx_L1_error) __pyx_r = __pyx_pf_5trade_5Trade_22accept(((struct __pyx_obj_5trade_Trade *)__pyx_v_self), __pyx_v_offer, __pyx_v_quantity, __pyx_v_epsilon); /* function exit code */ @@ -7974,7 +7970,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * PyObject *__pyx_t_12 = NULL; __Pyx_RefNannySetupContext("accept", 0); - /* "trade.pyx":577 + /* "trade.pyx":578 * """ * cdef double money_amount * cdef double offer_quantity = offer.quantity # <<<<<<<<<<<<<< @@ -7984,7 +7980,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * __pyx_t_1 = __pyx_v_offer->quantity; __pyx_v_offer_quantity = __pyx_t_1; - /* "trade.pyx":580 + /* "trade.pyx":581 * cdef double available * * if quantity == -999: # <<<<<<<<<<<<<< @@ -7994,7 +7990,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * __pyx_t_2 = ((__pyx_v_quantity == -999.0) != 0); if (__pyx_t_2) { - /* "trade.pyx":581 + /* "trade.pyx":582 * * if quantity == -999: * quantity = offer_quantity # <<<<<<<<<<<<<< @@ -8003,7 +7999,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * */ __pyx_v_quantity = __pyx_v_offer_quantity; - /* "trade.pyx":580 + /* "trade.pyx":581 * cdef double available * * if quantity == -999: # <<<<<<<<<<<<<< @@ -8012,7 +8008,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * */ } - /* "trade.pyx":582 + /* "trade.pyx":583 * if quantity == -999: * quantity = offer_quantity * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) # <<<<<<<<<<<<<< @@ -8022,11 +8018,11 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_quantity > (-__pyx_v_epsilon)) != 0))) { - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 582, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 583, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 582, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 583, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 582, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 583, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); @@ -8034,17 +8030,17 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); __pyx_t_3 = 0; __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_quantity_30f_is_smaller_than_0_e, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 582, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_quantity_30f_is_smaller_than_0_e, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 583, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(0, 582, __pyx_L1_error) + __PYX_ERR(0, 583, __pyx_L1_error) } } #endif - /* "trade.pyx":583 + /* "trade.pyx":584 * quantity = offer_quantity * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: # <<<<<<<<<<<<<< @@ -8054,7 +8050,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * __pyx_t_2 = ((__pyx_v_quantity < 0.0) != 0); if (__pyx_t_2) { - /* "trade.pyx":584 + /* "trade.pyx":585 * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: * quantity = 0 # <<<<<<<<<<<<<< @@ -8063,7 +8059,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * */ __pyx_v_quantity = 0.0; - /* "trade.pyx":583 + /* "trade.pyx":584 * quantity = offer_quantity * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: # <<<<<<<<<<<<<< @@ -8072,7 +8068,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * */ } - /* "trade.pyx":585 + /* "trade.pyx":586 * if quantity < 0: * quantity = 0 * if quantity > offer_quantity + epsilon * fmax(quantity, offer_quantity): # <<<<<<<<<<<<<< @@ -8082,18 +8078,18 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * __pyx_t_2 = ((__pyx_v_quantity > (__pyx_v_offer_quantity + (__pyx_v_epsilon * __pyx_f_5trade_fmax(__pyx_v_quantity, __pyx_v_offer_quantity)))) != 0); if (__pyx_t_2) { - /* "trade.pyx":587 + /* "trade.pyx":588 * if quantity > offer_quantity + epsilon * fmax(quantity, offer_quantity): * raise AssertionError('accepted more than offered %s: %.100f >= %.100f' * % (offer.good, quantity, offer_quantity)) # <<<<<<<<<<<<<< * if quantity > offer_quantity: * quantity = offer_quantity */ - __pyx_t_4 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 587, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 588, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyFloat_FromDouble(__pyx_v_offer_quantity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 587, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_offer_quantity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 588, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 587, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 588, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_offer->good); __Pyx_GIVEREF(__pyx_v_offer->good); @@ -8104,30 +8100,30 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_5); __pyx_t_4 = 0; __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_accepted_more_than_offered_s_100, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 587, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_accepted_more_than_offered_s_100, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 588, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "trade.pyx":586 + /* "trade.pyx":587 * quantity = 0 * if quantity > offer_quantity + epsilon * fmax(quantity, offer_quantity): * raise AssertionError('accepted more than offered %s: %.100f >= %.100f' # <<<<<<<<<<<<<< * % (offer.good, quantity, offer_quantity)) * if quantity > offer_quantity: */ - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 586, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 587, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_AssertionError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 586, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_AssertionError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 587, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __PYX_ERR(0, 586, __pyx_L1_error) + __PYX_ERR(0, 587, __pyx_L1_error) - /* "trade.pyx":585 + /* "trade.pyx":586 * if quantity < 0: * quantity = 0 * if quantity > offer_quantity + epsilon * fmax(quantity, offer_quantity): # <<<<<<<<<<<<<< @@ -8136,7 +8132,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * */ } - /* "trade.pyx":588 + /* "trade.pyx":589 * raise AssertionError('accepted more than offered %s: %.100f >= %.100f' * % (offer.good, quantity, offer_quantity)) * if quantity > offer_quantity: # <<<<<<<<<<<<<< @@ -8146,7 +8142,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * __pyx_t_2 = ((__pyx_v_quantity > __pyx_v_offer_quantity) != 0); if (__pyx_t_2) { - /* "trade.pyx":589 + /* "trade.pyx":590 * % (offer.good, quantity, offer_quantity)) * if quantity > offer_quantity: * quantity = offer_quantity # <<<<<<<<<<<<<< @@ -8155,7 +8151,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * */ __pyx_v_quantity = __pyx_v_offer_quantity; - /* "trade.pyx":588 + /* "trade.pyx":589 * raise AssertionError('accepted more than offered %s: %.100f >= %.100f' * % (offer.good, quantity, offer_quantity)) * if quantity > offer_quantity: # <<<<<<<<<<<<<< @@ -8164,7 +8160,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * */ } - /* "trade.pyx":591 + /* "trade.pyx":592 * quantity = offer_quantity * * if quantity == 0: # <<<<<<<<<<<<<< @@ -8174,14 +8170,14 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * __pyx_t_2 = ((__pyx_v_quantity == 0.0) != 0); if (__pyx_t_2) { - /* "trade.pyx":592 + /* "trade.pyx":593 * * if quantity == 0: * self.reject(offer) # <<<<<<<<<<<<<< * return {offer.good: 0, offer.currency: 0} * */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reject); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 592, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reject); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 593, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { @@ -8194,13 +8190,13 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * } } if (!__pyx_t_4) { - __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_offer)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 592, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_offer)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 593, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_offer)}; - __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 592, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 593, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_5); } else @@ -8208,19 +8204,19 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_offer)}; - __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 592, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 593, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 592, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 593, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; __Pyx_INCREF(((PyObject *)__pyx_v_offer)); __Pyx_GIVEREF(((PyObject *)__pyx_v_offer)); PyTuple_SET_ITEM(__pyx_t_6, 0+1, ((PyObject *)__pyx_v_offer)); - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 592, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 593, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } @@ -8228,7 +8224,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - /* "trade.pyx":593 + /* "trade.pyx":594 * if quantity == 0: * self.reject(offer) * return {offer.good: 0, offer.currency: 0} # <<<<<<<<<<<<<< @@ -8236,15 +8232,15 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * * money_amount = quantity * offer.price */ __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 593, __pyx_L1_error) + __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - if (PyDict_SetItem(__pyx_t_5, __pyx_v_offer->good, __pyx_int_0) < 0) __PYX_ERR(0, 593, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_5, __pyx_v_offer->currency, __pyx_int_0) < 0) __PYX_ERR(0, 593, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_5, __pyx_v_offer->good, __pyx_int_0) < 0) __PYX_ERR(0, 594, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_5, __pyx_v_offer->currency, __pyx_int_0) < 0) __PYX_ERR(0, 594, __pyx_L1_error) __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; - /* "trade.pyx":591 + /* "trade.pyx":592 * quantity = offer_quantity * * if quantity == 0: # <<<<<<<<<<<<<< @@ -8253,7 +8249,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * */ } - /* "trade.pyx":595 + /* "trade.pyx":596 * return {offer.good: 0, offer.currency: 0} * * money_amount = quantity * offer.price # <<<<<<<<<<<<<< @@ -8262,7 +8258,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * */ __pyx_v_money_amount = (__pyx_v_quantity * __pyx_v_offer->price); - /* "trade.pyx":596 + /* "trade.pyx":597 * * money_amount = quantity * offer.price * if offer.sell: # ord('s') # <<<<<<<<<<<<<< @@ -8272,7 +8268,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * __pyx_t_2 = (__pyx_v_offer->sell != 0); if (__pyx_t_2) { - /* "trade.pyx":597 + /* "trade.pyx":598 * money_amount = quantity * offer.price * if offer.sell: # ord('s') * assert money_amount > - epsilon, 'money = quantity * offer.price %.30f is smaller than 0 - epsilon (%.30f)' % (money_amount, - epsilon) # <<<<<<<<<<<<<< @@ -8282,11 +8278,11 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_money_amount > (-__pyx_v_epsilon)) != 0))) { - __pyx_t_5 = PyFloat_FromDouble(__pyx_v_money_amount); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 597, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_money_amount); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 598, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 597, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 598, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 597, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 598, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); @@ -8294,17 +8290,17 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3); __pyx_t_5 = 0; __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_money_quantity_offer_price_30f_i, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 597, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_money_quantity_offer_price_30f_i, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 598, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 597, __pyx_L1_error) + __PYX_ERR(0, 598, __pyx_L1_error) } } #endif - /* "trade.pyx":598 + /* "trade.pyx":599 * if offer.sell: # ord('s') * assert money_amount > - epsilon, 'money = quantity * offer.price %.30f is smaller than 0 - epsilon (%.30f)' % (money_amount, - epsilon) * if money_amount < 0: # <<<<<<<<<<<<<< @@ -8314,16 +8310,16 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * __pyx_t_2 = ((__pyx_v_money_amount < 0.0) != 0); if (__pyx_t_2) { - /* "trade.pyx":599 + /* "trade.pyx":600 * assert money_amount > - epsilon, 'money = quantity * offer.price %.30f is smaller than 0 - epsilon (%.30f)' % (money_amount, - epsilon) * if money_amount < 0: * money_amount = 0 # <<<<<<<<<<<<<< * - * available = self._haves[offer.currency] + * available = self._inventory[offer.currency] */ __pyx_v_money_amount = 0.0; - /* "trade.pyx":598 + /* "trade.pyx":599 * if offer.sell: # ord('s') * assert money_amount > - epsilon, 'money = quantity * offer.price %.30f is smaller than 0 - epsilon (%.30f)' % (money_amount, - epsilon) * if money_amount < 0: # <<<<<<<<<<<<<< @@ -8332,25 +8328,25 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * */ } - /* "trade.pyx":601 + /* "trade.pyx":602 * money_amount = 0 * - * available = self._haves[offer.currency] # <<<<<<<<<<<<<< + * available = self._inventory[offer.currency] # <<<<<<<<<<<<<< * if money_amount > available + epsilon + epsilon * max(money_amount, available): * raise NotEnoughGoods(self.name, offer.currency, money_amount - available) */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 601, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 602, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = PyObject_GetItem(__pyx_t_3, __pyx_v_offer->currency); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 601, __pyx_L1_error) + __pyx_t_6 = PyObject_GetItem(__pyx_t_3, __pyx_v_offer->currency); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 602, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 601, __pyx_L1_error) + __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 602, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_available = __pyx_t_1; - /* "trade.pyx":602 + /* "trade.pyx":603 * - * available = self._haves[offer.currency] + * available = self._inventory[offer.currency] * if money_amount > available + epsilon + epsilon * max(money_amount, available): # <<<<<<<<<<<<<< * raise NotEnoughGoods(self.name, offer.currency, money_amount - available) * if money_amount > available: @@ -8365,18 +8361,18 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * __pyx_t_2 = ((__pyx_v_money_amount > ((__pyx_v_available + __pyx_v_epsilon) + (__pyx_v_epsilon * __pyx_t_8))) != 0); if (__pyx_t_2) { - /* "trade.pyx":603 - * available = self._haves[offer.currency] + /* "trade.pyx":604 + * available = self._inventory[offer.currency] * if money_amount > available + epsilon + epsilon * max(money_amount, available): * raise NotEnoughGoods(self.name, offer.currency, money_amount - available) # <<<<<<<<<<<<<< * if money_amount > available: * money_amount = available */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_NotEnoughGoods); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 603, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_NotEnoughGoods); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 603, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyFloat_FromDouble((__pyx_v_money_amount - __pyx_v_available)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 603, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble((__pyx_v_money_amount - __pyx_v_available)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = NULL; __pyx_t_10 = 0; @@ -8393,7 +8389,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_5, __pyx_v_offer->currency, __pyx_t_4}; - __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 603, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; @@ -8403,7 +8399,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_5, __pyx_v_offer->currency, __pyx_t_4}; - __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 603, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; @@ -8411,7 +8407,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * } else #endif { - __pyx_t_11 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 603, __pyx_L1_error) + __pyx_t_11 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL; @@ -8425,101 +8421,107 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_t_4); __pyx_t_5 = 0; __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 603, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __PYX_ERR(0, 603, __pyx_L1_error) + __PYX_ERR(0, 604, __pyx_L1_error) - /* "trade.pyx":602 + /* "trade.pyx":603 * - * available = self._haves[offer.currency] + * available = self._inventory[offer.currency] * if money_amount > available + epsilon + epsilon * max(money_amount, available): # <<<<<<<<<<<<<< * raise NotEnoughGoods(self.name, offer.currency, money_amount - available) * if money_amount > available: */ } - /* "trade.pyx":604 + /* "trade.pyx":605 * if money_amount > available + epsilon + epsilon * max(money_amount, available): * raise NotEnoughGoods(self.name, offer.currency, money_amount - available) * if money_amount > available: # <<<<<<<<<<<<<< * money_amount = available - * self._haves[offer.good] += quantity + * self._inventory.haves[offer.good] += quantity */ __pyx_t_2 = ((__pyx_v_money_amount > __pyx_v_available) != 0); if (__pyx_t_2) { - /* "trade.pyx":605 + /* "trade.pyx":606 * raise NotEnoughGoods(self.name, offer.currency, money_amount - available) * if money_amount > available: * money_amount = available # <<<<<<<<<<<<<< - * self._haves[offer.good] += quantity - * self._haves[offer.currency] -= quantity * offer.price + * self._inventory.haves[offer.good] += quantity + * self._inventory.haves[offer.currency] -= quantity * offer.price */ __pyx_v_money_amount = __pyx_v_available; - /* "trade.pyx":604 + /* "trade.pyx":605 * if money_amount > available + epsilon + epsilon * max(money_amount, available): * raise NotEnoughGoods(self.name, offer.currency, money_amount - available) * if money_amount > available: # <<<<<<<<<<<<<< * money_amount = available - * self._haves[offer.good] += quantity + * self._inventory.haves[offer.good] += quantity */ } - /* "trade.pyx":606 + /* "trade.pyx":607 * if money_amount > available: * money_amount = available - * self._haves[offer.good] += quantity # <<<<<<<<<<<<<< - * self._haves[offer.currency] -= quantity * offer.price + * self._inventory.haves[offer.good] += quantity # <<<<<<<<<<<<<< + * self._inventory.haves[offer.currency] -= quantity * offer.price * else: */ - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 606, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 607, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_haves); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 607, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_INCREF(__pyx_v_offer->good); - __pyx_t_3 = __pyx_v_offer->good; - __pyx_t_11 = PyObject_GetItem(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 606, __pyx_L1_error) + __pyx_t_6 = __pyx_v_offer->good; + __pyx_t_11 = PyObject_GetItem(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 607, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_4 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 606, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 607, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_11, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 606, __pyx_L1_error) + __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_11, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 607, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_6, __pyx_t_3, __pyx_t_5) < 0)) __PYX_ERR(0, 606, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_3, __pyx_t_6, __pyx_t_5) < 0)) __PYX_ERR(0, 607, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "trade.pyx":607 + /* "trade.pyx":608 * money_amount = available - * self._haves[offer.good] += quantity - * self._haves[offer.currency] -= quantity * offer.price # <<<<<<<<<<<<<< + * self._inventory.haves[offer.good] += quantity + * self._inventory.haves[offer.currency] -= quantity * offer.price # <<<<<<<<<<<<<< * else: * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) */ - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 607, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 608, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_haves); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 608, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_v_offer->currency); __pyx_t_12 = __pyx_v_offer->currency; - __pyx_t_3 = PyObject_GetItem(__pyx_t_6, __pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 607, __pyx_L1_error) + __pyx_t_3 = PyObject_GetItem(__pyx_t_6, __pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 608, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyFloat_FromDouble((__pyx_v_quantity * __pyx_v_offer->price)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 607, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble((__pyx_v_quantity * __pyx_v_offer->price)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 608, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyNumber_InPlaceSubtract(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 607, __pyx_L1_error) + __pyx_t_4 = PyNumber_InPlaceSubtract(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 608, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_6, __pyx_t_12, __pyx_t_4) < 0)) __PYX_ERR(0, 607, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_6, __pyx_t_12, __pyx_t_4) < 0)) __PYX_ERR(0, 608, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "trade.pyx":596 + /* "trade.pyx":597 * * money_amount = quantity * offer.price * if offer.sell: # ord('s') # <<<<<<<<<<<<<< @@ -8529,8 +8531,8 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * goto __pyx_L8; } - /* "trade.pyx":609 - * self._haves[offer.currency] -= quantity * offer.price + /* "trade.pyx":610 + * self._inventory.haves[offer.currency] -= quantity * offer.price * else: * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) # <<<<<<<<<<<<<< * if quantity < 0: @@ -8540,11 +8542,11 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_quantity > (-__pyx_v_epsilon)) != 0))) { - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 609, __pyx_L1_error) + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 610, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 609, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 610, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 609, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 610, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); @@ -8552,63 +8554,63 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); __pyx_t_6 = 0; __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_quantity_30f_is_smaller_than_0_e, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 609, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_quantity_30f_is_smaller_than_0_e, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 610, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(0, 609, __pyx_L1_error) + __PYX_ERR(0, 610, __pyx_L1_error) } } #endif - /* "trade.pyx":610 + /* "trade.pyx":611 * else: * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: # <<<<<<<<<<<<<< * quantity = 0 - * available = self._haves[offer.good] + * available = self._inventory[offer.good] */ __pyx_t_2 = ((__pyx_v_quantity < 0.0) != 0); if (__pyx_t_2) { - /* "trade.pyx":611 + /* "trade.pyx":612 * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: * quantity = 0 # <<<<<<<<<<<<<< - * available = self._haves[offer.good] + * available = self._inventory[offer.good] * if quantity > available + epsilon + epsilon * max(quantity, available): */ __pyx_v_quantity = 0.0; - /* "trade.pyx":610 + /* "trade.pyx":611 * else: * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: # <<<<<<<<<<<<<< * quantity = 0 - * available = self._haves[offer.good] + * available = self._inventory[offer.good] */ } - /* "trade.pyx":612 + /* "trade.pyx":613 * if quantity < 0: * quantity = 0 - * available = self._haves[offer.good] # <<<<<<<<<<<<<< + * available = self._inventory[offer.good] # <<<<<<<<<<<<<< * if quantity > available + epsilon + epsilon * max(quantity, available): * raise NotEnoughGoods(self.name, offer.good, quantity - available) */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 612, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 613, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyObject_GetItem(__pyx_t_4, __pyx_v_offer->good); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 612, __pyx_L1_error) + __pyx_t_5 = PyObject_GetItem(__pyx_t_4, __pyx_v_offer->good); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 613, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 612, __pyx_L1_error) + __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 613, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_available = __pyx_t_8; - /* "trade.pyx":613 + /* "trade.pyx":614 * quantity = 0 - * available = self._haves[offer.good] + * available = self._inventory[offer.good] * if quantity > available + epsilon + epsilon * max(quantity, available): # <<<<<<<<<<<<<< * raise NotEnoughGoods(self.name, offer.good, quantity - available) * if quantity > available: @@ -8623,18 +8625,18 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * __pyx_t_2 = ((__pyx_v_quantity > ((__pyx_v_available + __pyx_v_epsilon) + (__pyx_v_epsilon * __pyx_t_7))) != 0); if (__pyx_t_2) { - /* "trade.pyx":614 - * available = self._haves[offer.good] + /* "trade.pyx":615 + * available = self._inventory[offer.good] * if quantity > available + epsilon + epsilon * max(quantity, available): * raise NotEnoughGoods(self.name, offer.good, quantity - available) # <<<<<<<<<<<<<< * if quantity > available: * quantity = available */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_NotEnoughGoods); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 614, __pyx_L1_error) + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_NotEnoughGoods); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 614, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_3 = PyFloat_FromDouble((__pyx_v_quantity - __pyx_v_available)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 614, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble((__pyx_v_quantity - __pyx_v_available)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_11 = NULL; __pyx_t_10 = 0; @@ -8651,7 +8653,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_t_6, __pyx_v_offer->good, __pyx_t_3}; - __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 614, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 615, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -8661,7 +8663,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_11, __pyx_t_6, __pyx_v_offer->good, __pyx_t_3}; - __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 614, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 615, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -8669,7 +8671,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * } else #endif { - __pyx_t_9 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 614, __pyx_L1_error) + __pyx_t_9 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_11) { __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_11); __pyx_t_11 = NULL; @@ -8683,125 +8685,131 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_10, __pyx_t_3); __pyx_t_6 = 0; __pyx_t_3 = 0; - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 614, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __PYX_ERR(0, 614, __pyx_L1_error) + __PYX_ERR(0, 615, __pyx_L1_error) - /* "trade.pyx":613 + /* "trade.pyx":614 * quantity = 0 - * available = self._haves[offer.good] + * available = self._inventory[offer.good] * if quantity > available + epsilon + epsilon * max(quantity, available): # <<<<<<<<<<<<<< * raise NotEnoughGoods(self.name, offer.good, quantity - available) * if quantity > available: */ } - /* "trade.pyx":615 + /* "trade.pyx":616 * if quantity > available + epsilon + epsilon * max(quantity, available): * raise NotEnoughGoods(self.name, offer.good, quantity - available) * if quantity > available: # <<<<<<<<<<<<<< * quantity = available - * self._haves[offer.good] -= quantity + * self._inventory.haves[offer.good] -= quantity */ __pyx_t_2 = ((__pyx_v_quantity > __pyx_v_available) != 0); if (__pyx_t_2) { - /* "trade.pyx":616 + /* "trade.pyx":617 * raise NotEnoughGoods(self.name, offer.good, quantity - available) * if quantity > available: * quantity = available # <<<<<<<<<<<<<< - * self._haves[offer.good] -= quantity - * self._haves[offer.currency] += quantity * offer.price + * self._inventory.haves[offer.good] -= quantity + * self._inventory.haves[offer.currency] += quantity * offer.price */ __pyx_v_quantity = __pyx_v_available; - /* "trade.pyx":615 + /* "trade.pyx":616 * if quantity > available + epsilon + epsilon * max(quantity, available): * raise NotEnoughGoods(self.name, offer.good, quantity - available) * if quantity > available: # <<<<<<<<<<<<<< * quantity = available - * self._haves[offer.good] -= quantity + * self._inventory.haves[offer.good] -= quantity */ } - /* "trade.pyx":617 + /* "trade.pyx":618 * if quantity > available: * quantity = available - * self._haves[offer.good] -= quantity # <<<<<<<<<<<<<< - * self._haves[offer.currency] += quantity * offer.price + * self._inventory.haves[offer.good] -= quantity # <<<<<<<<<<<<<< + * self._inventory.haves[offer.currency] += quantity * offer.price * offer.final_quantity = quantity */ - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 617, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_haves); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 618, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_v_offer->good); - __pyx_t_4 = __pyx_v_offer->good; - __pyx_t_9 = PyObject_GetItem(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 617, __pyx_L1_error) + __pyx_t_5 = __pyx_v_offer->good; + __pyx_t_9 = PyObject_GetItem(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 617, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = PyNumber_InPlaceSubtract(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 617, __pyx_L1_error) + __pyx_t_6 = PyNumber_InPlaceSubtract(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_t_4, __pyx_t_6) < 0)) __PYX_ERR(0, 617, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_4, __pyx_t_5, __pyx_t_6) < 0)) __PYX_ERR(0, 618, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "trade.pyx":618 + /* "trade.pyx":619 * quantity = available - * self._haves[offer.good] -= quantity - * self._haves[offer.currency] += quantity * offer.price # <<<<<<<<<<<<<< + * self._inventory.haves[offer.good] -= quantity + * self._inventory.haves[offer.currency] += quantity * offer.price # <<<<<<<<<<<<<< * offer.final_quantity = quantity * self._send(offer.sender_group, offer.sender_id, '_p', (offer.id, quantity)) */ - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 618, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 619, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_haves); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_v_offer->currency); __pyx_t_12 = __pyx_v_offer->currency; - __pyx_t_4 = PyObject_GetItem(__pyx_t_5, __pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 618, __pyx_L1_error) + __pyx_t_4 = PyObject_GetItem(__pyx_t_5, __pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyFloat_FromDouble((__pyx_v_quantity * __pyx_v_offer->price)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 618, __pyx_L1_error) + __pyx_t_6 = PyFloat_FromDouble((__pyx_v_quantity * __pyx_v_offer->price)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 618, __pyx_L1_error) + __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_t_12, __pyx_t_3) < 0)) __PYX_ERR(0, 618, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_t_12, __pyx_t_3) < 0)) __PYX_ERR(0, 619, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_L8:; - /* "trade.pyx":619 - * self._haves[offer.good] -= quantity - * self._haves[offer.currency] += quantity * offer.price + /* "trade.pyx":620 + * self._inventory.haves[offer.good] -= quantity + * self._inventory.haves[offer.currency] += quantity * offer.price * offer.final_quantity = quantity # <<<<<<<<<<<<<< * self._send(offer.sender_group, offer.sender_id, '_p', (offer.id, quantity)) * del self._polled_offers[offer.id] */ __pyx_v_offer->final_quantity = __pyx_v_quantity; - /* "trade.pyx":620 - * self._haves[offer.currency] += quantity * offer.price + /* "trade.pyx":621 + * self._inventory.haves[offer.currency] += quantity * offer.price * offer.final_quantity = quantity * self._send(offer.sender_group, offer.sender_id, '_p', (offer.id, quantity)) # <<<<<<<<<<<<<< * del self._polled_offers[offer.id] * if offer.sell: # ord('s') */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 620, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_offer->sender_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 620, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_offer->sender_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 620, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 620, __pyx_L1_error) + __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_v_offer->id); __Pyx_GIVEREF(__pyx_v_offer->id); @@ -8824,7 +8832,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_offer->sender_group, __pyx_t_6, __pyx_n_s_p, __pyx_t_9}; - __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 620, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 621, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -8834,7 +8842,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_offer->sender_group, __pyx_t_6, __pyx_n_s_p, __pyx_t_9}; - __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 620, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 621, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -8842,7 +8850,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * } else #endif { - __pyx_t_11 = PyTuple_New(4+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 620, __pyx_L1_error) + __pyx_t_11 = PyTuple_New(4+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4); __pyx_t_4 = NULL; @@ -8859,26 +8867,26 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_10, __pyx_t_9); __pyx_t_6 = 0; __pyx_t_9 = 0; - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 620, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - /* "trade.pyx":621 + /* "trade.pyx":622 * offer.final_quantity = quantity * self._send(offer.sender_group, offer.sender_id, '_p', (offer.id, quantity)) * del self._polled_offers[offer.id] # <<<<<<<<<<<<<< * if offer.sell: # ord('s') * return {offer.good: - quantity, offer.currency: money_amount} */ - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_polled_offers); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 621, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_polled_offers); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 622, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - if (unlikely(PyObject_DelItem(__pyx_t_5, __pyx_v_offer->id) < 0)) __PYX_ERR(0, 621, __pyx_L1_error) + if (unlikely(PyObject_DelItem(__pyx_t_5, __pyx_v_offer->id) < 0)) __PYX_ERR(0, 622, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - /* "trade.pyx":622 + /* "trade.pyx":623 * self._send(offer.sender_group, offer.sender_id, '_p', (offer.id, quantity)) * del self._polled_offers[offer.id] * if offer.sell: # ord('s') # <<<<<<<<<<<<<< @@ -8888,7 +8896,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * __pyx_t_2 = (__pyx_v_offer->sell != 0); if (__pyx_t_2) { - /* "trade.pyx":623 + /* "trade.pyx":624 * del self._polled_offers[offer.id] * if offer.sell: # ord('s') * return {offer.good: - quantity, offer.currency: money_amount} # <<<<<<<<<<<<<< @@ -8896,21 +8904,21 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * * return {offer.good: quantity, offer.currency: - money_amount} */ __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 623, __pyx_L1_error) + __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 624, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyFloat_FromDouble((-__pyx_v_quantity)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 623, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble((-__pyx_v_quantity)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 624, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_5, __pyx_v_offer->good, __pyx_t_3) < 0) __PYX_ERR(0, 623, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_5, __pyx_v_offer->good, __pyx_t_3) < 0) __PYX_ERR(0, 624, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_money_amount); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 623, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_money_amount); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 624, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_5, __pyx_v_offer->currency, __pyx_t_3) < 0) __PYX_ERR(0, 623, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_5, __pyx_v_offer->currency, __pyx_t_3) < 0) __PYX_ERR(0, 624, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; - /* "trade.pyx":622 + /* "trade.pyx":623 * self._send(offer.sender_group, offer.sender_id, '_p', (offer.id, quantity)) * del self._polled_offers[offer.id] * if offer.sell: # ord('s') # <<<<<<<<<<<<<< @@ -8919,7 +8927,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * */ } - /* "trade.pyx":625 + /* "trade.pyx":626 * return {offer.good: - quantity, offer.currency: money_amount} * else: * return {offer.good: quantity, offer.currency: - money_amount} # <<<<<<<<<<<<<< @@ -8928,22 +8936,22 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * */ /*else*/ { __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 625, __pyx_L1_error) + __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 626, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 625, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 626, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_5, __pyx_v_offer->good, __pyx_t_3) < 0) __PYX_ERR(0, 625, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_5, __pyx_v_offer->good, __pyx_t_3) < 0) __PYX_ERR(0, 626, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyFloat_FromDouble((-__pyx_v_money_amount)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 625, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble((-__pyx_v_money_amount)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 626, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_5, __pyx_v_offer->currency, __pyx_t_3) < 0) __PYX_ERR(0, 625, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_5, __pyx_v_offer->currency, __pyx_t_3) < 0) __PYX_ERR(0, 626, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; } - /* "trade.pyx":556 + /* "trade.pyx":557 * return offer * * def accept(self, Offer offer, double quantity=-999, double epsilon=epsilon): # <<<<<<<<<<<<<< @@ -8968,7 +8976,7 @@ static PyObject *__pyx_pf_5trade_5Trade_22accept(struct __pyx_obj_5trade_Trade * return __pyx_r; } -/* "trade.pyx":628 +/* "trade.pyx":629 * * * def _reject_polled_but_not_accepted_offers(self): # <<<<<<<<<<<<<< @@ -9000,16 +9008,16 @@ static PyObject *__pyx_pf_5trade_5Trade_24_reject_polled_but_not_accepted_offers PyObject *(*__pyx_t_5)(PyObject *); __Pyx_RefNannySetupContext("_reject_polled_but_not_accepted_offers", 0); - /* "trade.pyx":630 + /* "trade.pyx":631 * def _reject_polled_but_not_accepted_offers(self): * cdef Offer offer * for offer in self._polled_offers.values(): # <<<<<<<<<<<<<< * self._reject(offer) * self._polled_offers = {} */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_polled_offers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 630, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_polled_offers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_values); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 630, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_values); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; @@ -9023,10 +9031,10 @@ static PyObject *__pyx_pf_5trade_5Trade_24_reject_polled_but_not_accepted_offers } } if (__pyx_t_2) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 630, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 630, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 631, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -9034,9 +9042,9 @@ static PyObject *__pyx_pf_5trade_5Trade_24_reject_polled_but_not_accepted_offers __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { - __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 630, __pyx_L1_error) + __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 630, __pyx_L1_error) + __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 631, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { @@ -9044,17 +9052,17 @@ static PyObject *__pyx_pf_5trade_5Trade_24_reject_polled_but_not_accepted_offers if (likely(PyList_CheckExact(__pyx_t_3))) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 630, __pyx_L1_error) + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 631, __pyx_L1_error) #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 630, __pyx_L1_error) + __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 630, __pyx_L1_error) + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 631, __pyx_L1_error) #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 630, __pyx_L1_error) + __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } @@ -9064,28 +9072,28 @@ static PyObject *__pyx_pf_5trade_5Trade_24_reject_polled_but_not_accepted_offers PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 630, __pyx_L1_error) + else __PYX_ERR(0, 631, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5trade_Offer))))) __PYX_ERR(0, 630, __pyx_L1_error) + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5trade_Offer))))) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_offer, ((struct __pyx_obj_5trade_Offer *)__pyx_t_1)); __pyx_t_1 = 0; - /* "trade.pyx":631 + /* "trade.pyx":632 * cdef Offer offer * for offer in self._polled_offers.values(): * self._reject(offer) # <<<<<<<<<<<<<< * self._polled_offers = {} * */ - __pyx_t_1 = ((struct __pyx_vtabstruct_5trade_Trade *)__pyx_v_self->__pyx_vtab)->_reject(__pyx_v_self, __pyx_v_offer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 631, __pyx_L1_error) + __pyx_t_1 = ((struct __pyx_vtabstruct_5trade_Trade *)__pyx_v_self->__pyx_vtab)->_reject(__pyx_v_self, __pyx_v_offer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 632, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":630 + /* "trade.pyx":631 * def _reject_polled_but_not_accepted_offers(self): * cdef Offer offer * for offer in self._polled_offers.values(): # <<<<<<<<<<<<<< @@ -9095,19 +9103,19 @@ static PyObject *__pyx_pf_5trade_5Trade_24_reject_polled_but_not_accepted_offers } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "trade.pyx":632 + /* "trade.pyx":633 * for offer in self._polled_offers.values(): * self._reject(offer) * self._polled_offers = {} # <<<<<<<<<<<<<< * * cdef _reject(self, Offer offer): */ - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 632, __pyx_L1_error) + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 633, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_polled_offers, __pyx_t_3) < 0) __PYX_ERR(0, 632, __pyx_L1_error) + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_polled_offers, __pyx_t_3) < 0) __PYX_ERR(0, 633, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "trade.pyx":628 + /* "trade.pyx":629 * * * def _reject_polled_but_not_accepted_offers(self): # <<<<<<<<<<<<<< @@ -9131,7 +9139,7 @@ static PyObject *__pyx_pf_5trade_5Trade_24_reject_polled_but_not_accepted_offers return __pyx_r; } -/* "trade.pyx":634 +/* "trade.pyx":635 * self._polled_offers = {} * * cdef _reject(self, Offer offer): # <<<<<<<<<<<<<< @@ -9150,16 +9158,16 @@ static PyObject *__pyx_f_5trade_5Trade__reject(struct __pyx_obj_5trade_Trade *__ PyObject *__pyx_t_6 = NULL; __Pyx_RefNannySetupContext("_reject", 0); - /* "trade.pyx":642 + /* "trade.pyx":643 * (offer not quote!) * """ * self._send(offer.sender_group, offer.sender_id, '_r', offer.id) # <<<<<<<<<<<<<< * * def reject(self, Offer offer): */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 642, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 643, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_offer->sender_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 642, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_offer->sender_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 643, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; @@ -9176,7 +9184,7 @@ static PyObject *__pyx_f_5trade_5Trade__reject(struct __pyx_obj_5trade_Trade *__ #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_offer->sender_group, __pyx_t_3, __pyx_n_s_r, __pyx_v_offer->id}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 642, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 643, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -9185,14 +9193,14 @@ static PyObject *__pyx_f_5trade_5Trade__reject(struct __pyx_obj_5trade_Trade *__ #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_offer->sender_group, __pyx_t_3, __pyx_n_s_r, __pyx_v_offer->id}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 642, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 643, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { - __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 642, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 643, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; @@ -9209,14 +9217,14 @@ static PyObject *__pyx_f_5trade_5Trade__reject(struct __pyx_obj_5trade_Trade *__ __Pyx_GIVEREF(__pyx_v_offer->id); PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_offer->id); __pyx_t_3 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 642, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 643, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":634 + /* "trade.pyx":635 * self._polled_offers = {} * * cdef _reject(self, Offer offer): # <<<<<<<<<<<<<< @@ -9241,7 +9249,7 @@ static PyObject *__pyx_f_5trade_5Trade__reject(struct __pyx_obj_5trade_Trade *__ return __pyx_r; } -/* "trade.pyx":644 +/* "trade.pyx":645 * self._send(offer.sender_group, offer.sender_id, '_r', offer.id) * * def reject(self, Offer offer): # <<<<<<<<<<<<<< @@ -9256,7 +9264,7 @@ static PyObject *__pyx_pw_5trade_5Trade_27reject(PyObject *__pyx_v_self, PyObjec PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("reject (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_offer), __pyx_ptype_5trade_Offer, 1, "offer", 0))) __PYX_ERR(0, 644, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_offer), __pyx_ptype_5trade_Offer, 1, "offer", 0))) __PYX_ERR(0, 645, __pyx_L1_error) __pyx_r = __pyx_pf_5trade_5Trade_26reject(((struct __pyx_obj_5trade_Trade *)__pyx_v_self), ((struct __pyx_obj_5trade_Offer *)__pyx_v_offer)); /* function exit code */ @@ -9280,7 +9288,7 @@ static PyObject *__pyx_pf_5trade_5Trade_26reject(CYTHON_UNUSED struct __pyx_obj_ return __pyx_r; } -/* "trade.pyx":655 +/* "trade.pyx":656 * pass * * def _log_receive_accept_group(self, offer): # <<<<<<<<<<<<<< @@ -9313,37 +9321,37 @@ static PyObject *__pyx_pf_5trade_5Trade_28_log_receive_accept_group(struct __pyx PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("_log_receive_accept_group", 0); - /* "trade.pyx":656 + /* "trade.pyx":657 * * def _log_receive_accept_group(self, offer): * if offer.sell: # <<<<<<<<<<<<<< * self._trade_log[(offer.good, self.group, offer.receiver_group, offer.price)] += offer.quantity * else: */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_sell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 656, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_sell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 657, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 656, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 657, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "trade.pyx":657 + /* "trade.pyx":658 * def _log_receive_accept_group(self, offer): * if offer.sell: * self._trade_log[(offer.good, self.group, offer.receiver_group, offer.price)] += offer.quantity # <<<<<<<<<<<<<< * else: * self._trade_log[(offer.good, offer.receiver_group, self.group, offer.price)] += offer.quantity */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 657, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 658, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 657, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 658, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 657, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 658, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_group); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 657, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_group); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 658, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 657, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 658, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 657, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 658, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); @@ -9357,20 +9365,20 @@ static PyObject *__pyx_pf_5trade_5Trade_28_log_receive_accept_group(struct __pyx __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; - __pyx_t_6 = PyObject_GetItem(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 657, __pyx_L1_error) + __pyx_t_6 = PyObject_GetItem(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 658, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_quantity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 657, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_quantity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 658, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 657, __pyx_L1_error) + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 658, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_7, __pyx_t_4) < 0)) __PYX_ERR(0, 657, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_7, __pyx_t_4) < 0)) __PYX_ERR(0, 658, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":656 + /* "trade.pyx":657 * * def _log_receive_accept_group(self, offer): * if offer.sell: # <<<<<<<<<<<<<< @@ -9380,7 +9388,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28_log_receive_accept_group(struct __pyx goto __pyx_L3; } - /* "trade.pyx":659 + /* "trade.pyx":660 * self._trade_log[(offer.good, self.group, offer.receiver_group, offer.price)] += offer.quantity * else: * self._trade_log[(offer.good, offer.receiver_group, self.group, offer.price)] += offer.quantity # <<<<<<<<<<<<<< @@ -9388,17 +9396,17 @@ static PyObject *__pyx_pf_5trade_5Trade_28_log_receive_accept_group(struct __pyx * def _log_receive_accept_agent(self, offer): */ /*else*/ { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 659, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 660, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 659, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 660, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 659, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 660, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_group); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 659, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_group); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 660, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 659, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 660, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 659, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 660, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); @@ -9412,22 +9420,22 @@ static PyObject *__pyx_pf_5trade_5Trade_28_log_receive_accept_group(struct __pyx __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; - __pyx_t_6 = PyObject_GetItem(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 659, __pyx_L1_error) + __pyx_t_6 = PyObject_GetItem(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 660, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_quantity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 659, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_quantity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 660, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 659, __pyx_L1_error) + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 660, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_3, __pyx_t_4) < 0)) __PYX_ERR(0, 659, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_3, __pyx_t_4) < 0)) __PYX_ERR(0, 660, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L3:; - /* "trade.pyx":655 + /* "trade.pyx":656 * pass * * def _log_receive_accept_group(self, offer): # <<<<<<<<<<<<<< @@ -9453,7 +9461,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28_log_receive_accept_group(struct __pyx return __pyx_r; } -/* "trade.pyx":661 +/* "trade.pyx":662 * self._trade_log[(offer.good, offer.receiver_group, self.group, offer.price)] += offer.quantity * * def _log_receive_accept_agent(self, offer): # <<<<<<<<<<<<<< @@ -9486,37 +9494,37 @@ static PyObject *__pyx_pf_5trade_5Trade_30_log_receive_accept_agent(struct __pyx PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("_log_receive_accept_agent", 0); - /* "trade.pyx":662 + /* "trade.pyx":663 * * def _log_receive_accept_agent(self, offer): * if offer.sell: # <<<<<<<<<<<<<< * self._trade_log[(offer.good, self.name_without_colon, '%s_%i' % (offer.receiver_group, offer.receiver_id), offer.price)] += offer.quantity * else: */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_sell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 662, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_sell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 663, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 662, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 663, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "trade.pyx":663 + /* "trade.pyx":664 * def _log_receive_accept_agent(self, offer): * if offer.sell: * self._trade_log[(offer.good, self.name_without_colon, '%s_%i' % (offer.receiver_group, offer.receiver_id), offer.price)] += offer.quantity # <<<<<<<<<<<<<< * else: * self._trade_log[(offer.good, '%s_%i' % (offer.receiver_group, offer.receiver_id), self.name_without_colon, offer.price)] += offer.quantity */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 663, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 663, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name_without_colon); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 663, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name_without_colon); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_group); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 663, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_group); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 663, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 663, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); @@ -9524,12 +9532,12 @@ static PyObject *__pyx_pf_5trade_5Trade_30_log_receive_accept_agent(struct __pyx PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6); __pyx_t_5 = 0; __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_s__i, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 663, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_s__i, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 663, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 663, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); @@ -9543,20 +9551,20 @@ static PyObject *__pyx_pf_5trade_5Trade_30_log_receive_accept_agent(struct __pyx __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; - __pyx_t_7 = PyObject_GetItem(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 663, __pyx_L1_error) + __pyx_t_7 = PyObject_GetItem(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_quantity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 663, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_quantity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 663, __pyx_L1_error) + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_5, __pyx_t_4) < 0)) __PYX_ERR(0, 663, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_5, __pyx_t_4) < 0)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":662 + /* "trade.pyx":663 * * def _log_receive_accept_agent(self, offer): * if offer.sell: # <<<<<<<<<<<<<< @@ -9566,7 +9574,7 @@ static PyObject *__pyx_pf_5trade_5Trade_30_log_receive_accept_agent(struct __pyx goto __pyx_L3; } - /* "trade.pyx":665 + /* "trade.pyx":666 * self._trade_log[(offer.good, self.name_without_colon, '%s_%i' % (offer.receiver_group, offer.receiver_id), offer.price)] += offer.quantity * else: * self._trade_log[(offer.good, '%s_%i' % (offer.receiver_group, offer.receiver_id), self.name_without_colon, offer.price)] += offer.quantity # <<<<<<<<<<<<<< @@ -9574,15 +9582,15 @@ static PyObject *__pyx_pf_5trade_5Trade_30_log_receive_accept_agent(struct __pyx * def _receive_accept(self, offer_id_final_quantity): */ /*else*/ { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 665, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 666, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 665, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 666, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 665, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 666, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 665, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 666, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 665, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 666, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); @@ -9590,14 +9598,14 @@ static PyObject *__pyx_pf_5trade_5Trade_30_log_receive_accept_agent(struct __pyx PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6); __pyx_t_4 = 0; __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_s__i, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 665, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_s__i, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 666, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name_without_colon); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 665, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name_without_colon); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 666, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 665, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 666, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 665, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 666, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); @@ -9611,22 +9619,22 @@ static PyObject *__pyx_pf_5trade_5Trade_30_log_receive_accept_agent(struct __pyx __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_4 = 0; - __pyx_t_4 = PyObject_GetItem(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 665, __pyx_L1_error) + __pyx_t_4 = PyObject_GetItem(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 666, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_quantity); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 665, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_quantity); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 666, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 665, __pyx_L1_error) + __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 666, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_3, __pyx_t_6) < 0)) __PYX_ERR(0, 665, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_3, __pyx_t_6) < 0)) __PYX_ERR(0, 666, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L3:; - /* "trade.pyx":661 + /* "trade.pyx":662 * self._trade_log[(offer.good, offer.receiver_group, self.group, offer.price)] += offer.quantity * * def _log_receive_accept_agent(self, offer): # <<<<<<<<<<<<<< @@ -9652,7 +9660,7 @@ static PyObject *__pyx_pf_5trade_5Trade_30_log_receive_accept_agent(struct __pyx return __pyx_r; } -/* "trade.pyx":667 +/* "trade.pyx":668 * self._trade_log[(offer.good, '%s_%i' % (offer.receiver_group, offer.receiver_id), self.name_without_colon, offer.price)] += offer.quantity * * def _receive_accept(self, offer_id_final_quantity): # <<<<<<<<<<<<<< @@ -9685,164 +9693,263 @@ static PyObject *__pyx_pf_5trade_5Trade_32_receive_accept(struct __pyx_obj_5trad int __pyx_t_5; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_t_9; + int __pyx_t_8; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; __Pyx_RefNannySetupContext("_receive_accept", 0); - /* "trade.pyx":672 + /* "trade.pyx":673 * is deleted * """ * cdef Offer offer = self.given_offers[offer_id_final_quantity[0]] # <<<<<<<<<<<<<< * offer.final_quantity = offer_id_final_quantity[1] * if offer.sell: */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_given_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 672, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_given_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 673, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_offer_id_final_quantity, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 672, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_offer_id_final_quantity, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 673, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_GetItem(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 672, __pyx_L1_error) + __pyx_t_3 = PyObject_GetItem(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 673, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5trade_Offer))))) __PYX_ERR(0, 672, __pyx_L1_error) + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5trade_Offer))))) __PYX_ERR(0, 673, __pyx_L1_error) __pyx_v_offer = ((struct __pyx_obj_5trade_Offer *)__pyx_t_3); __pyx_t_3 = 0; - /* "trade.pyx":673 + /* "trade.pyx":674 * """ * cdef Offer offer = self.given_offers[offer_id_final_quantity[0]] * offer.final_quantity = offer_id_final_quantity[1] # <<<<<<<<<<<<<< * if offer.sell: - * self._haves['money'] += offer.final_quantity * offer.price + * self._inventory.commit(offer.good, offer.quantity, offer.final_quantity) */ - __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_offer_id_final_quantity, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 673, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_offer_id_final_quantity, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 674, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_4 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 673, __pyx_L1_error) + __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_4 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 674, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_offer->final_quantity = __pyx_t_4; - /* "trade.pyx":674 + /* "trade.pyx":675 * cdef Offer offer = self.given_offers[offer_id_final_quantity[0]] * offer.final_quantity = offer_id_final_quantity[1] * if offer.sell: # <<<<<<<<<<<<<< - * self._haves['money'] += offer.final_quantity * offer.price - * self._haves[offer.good] += offer.quantity - offer.final_quantity + * self._inventory.commit(offer.good, offer.quantity, offer.final_quantity) + * self._inventory.haves[offer.currency] += offer.final_quantity * offer.price */ __pyx_t_5 = (__pyx_v_offer->sell != 0); if (__pyx_t_5) { - /* "trade.pyx":675 + /* "trade.pyx":676 * offer.final_quantity = offer_id_final_quantity[1] * if offer.sell: - * self._haves['money'] += offer.final_quantity * offer.price # <<<<<<<<<<<<<< - * self._haves[offer.good] += offer.quantity - offer.final_quantity + * self._inventory.commit(offer.good, offer.quantity, offer.final_quantity) # <<<<<<<<<<<<<< + * self._inventory.haves[offer.currency] += offer.final_quantity * offer.price * else: */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 675, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(__pyx_n_s_money); - __pyx_t_6 = __pyx_n_s_money; - __pyx_t_2 = PyObject_GetItem(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 675, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 676, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyFloat_FromDouble((__pyx_v_offer->final_quantity * __pyx_v_offer->price)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 675, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_commit); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 676, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 675, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_offer->quantity); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 676, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_offer->final_quantity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 676, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = NULL; + __pyx_t_8 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_7)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_7); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + __pyx_t_8 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_offer->good, __pyx_t_2, __pyx_t_6}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 676, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_offer->good, __pyx_t_2, __pyx_t_6}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 676, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } else + #endif + { + __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 676, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + if (__pyx_t_7) { + __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; + } + __Pyx_INCREF(__pyx_v_offer->good); + __Pyx_GIVEREF(__pyx_v_offer->good); + PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_v_offer->good); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_6); + __pyx_t_2 = 0; + __pyx_t_6 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 676, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_3, __pyx_t_6, __pyx_t_7) < 0)) __PYX_ERR(0, 675, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "trade.pyx":676 + /* "trade.pyx":677 * if offer.sell: - * self._haves['money'] += offer.final_quantity * offer.price - * self._haves[offer.good] += offer.quantity - offer.final_quantity # <<<<<<<<<<<<<< + * self._inventory.commit(offer.good, offer.quantity, offer.final_quantity) + * self._inventory.haves[offer.currency] += offer.final_quantity * offer.price # <<<<<<<<<<<<<< * else: - * self._haves[offer.good] += offer.final_quantity + * self._inventory.haves[offer.good] += offer.final_quantity */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 676, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 677, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(__pyx_v_offer->good); - __pyx_t_7 = __pyx_v_offer->good; - __pyx_t_1 = PyObject_GetItem(__pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 676, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_haves); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 677, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyFloat_FromDouble((__pyx_v_offer->quantity - __pyx_v_offer->final_quantity)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 676, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_8 = PyNumber_InPlaceAdd(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 676, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_3, __pyx_t_7, __pyx_t_8) < 0)) __PYX_ERR(0, 676, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_INCREF(__pyx_v_offer->currency); + __pyx_t_10 = __pyx_v_offer->currency; + __pyx_t_3 = PyObject_GetItem(__pyx_t_1, __pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 677, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_9 = PyFloat_FromDouble((__pyx_v_offer->final_quantity * __pyx_v_offer->price)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 677, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 677, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_10, __pyx_t_6) < 0)) __PYX_ERR(0, 677, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":674 + /* "trade.pyx":675 * cdef Offer offer = self.given_offers[offer_id_final_quantity[0]] * offer.final_quantity = offer_id_final_quantity[1] * if offer.sell: # <<<<<<<<<<<<<< - * self._haves['money'] += offer.final_quantity * offer.price - * self._haves[offer.good] += offer.quantity - offer.final_quantity + * self._inventory.commit(offer.good, offer.quantity, offer.final_quantity) + * self._inventory.haves[offer.currency] += offer.final_quantity * offer.price */ goto __pyx_L3; } - /* "trade.pyx":678 - * self._haves[offer.good] += offer.quantity - offer.final_quantity + /* "trade.pyx":679 + * self._inventory.haves[offer.currency] += offer.final_quantity * offer.price * else: - * self._haves[offer.good] += offer.final_quantity # <<<<<<<<<<<<<< - * self._haves['money'] += (offer.quantity - offer.final_quantity) * offer.price + * self._inventory.haves[offer.good] += offer.final_quantity # <<<<<<<<<<<<<< + * self._inventory.commit(offer.currency, offer.quantity * offer.price, offer.final_quantity * offer.price) * offer.status = "accepted" */ /*else*/ { - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 678, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 679, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_haves); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 679, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_v_offer->good); - __pyx_t_7 = __pyx_v_offer->good; - __pyx_t_8 = PyObject_GetItem(__pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 678, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_offer->final_quantity); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 678, __pyx_L1_error) + __pyx_t_1 = __pyx_v_offer->good; + __pyx_t_9 = PyObject_GetItem(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 679, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_offer->final_quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 679, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 679, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_t_8, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 678, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(PyObject_SetItem(__pyx_t_6, __pyx_t_1, __pyx_t_2) < 0)) __PYX_ERR(0, 679, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_3, __pyx_t_7, __pyx_t_1) < 0)) __PYX_ERR(0, 678, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "trade.pyx":679 + /* "trade.pyx":680 * else: - * self._haves[offer.good] += offer.final_quantity - * self._haves['money'] += (offer.quantity - offer.final_quantity) * offer.price # <<<<<<<<<<<<<< + * self._inventory.haves[offer.good] += offer.final_quantity + * self._inventory.commit(offer.currency, offer.quantity * offer.price, offer.final_quantity * offer.price) # <<<<<<<<<<<<<< * offer.status = "accepted" * offer.status_round = self.round */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 679, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(__pyx_n_s_money); - __pyx_t_6 = __pyx_n_s_money; - __pyx_t_7 = PyObject_GetItem(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 679, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_1 = PyFloat_FromDouble(((__pyx_v_offer->quantity - __pyx_v_offer->final_quantity) * __pyx_v_offer->price)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 679, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 680, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_t_7, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 679, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_commit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 680, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_3, __pyx_t_6, __pyx_t_2) < 0)) __PYX_ERR(0, 679, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble((__pyx_v_offer->quantity * __pyx_v_offer->price)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 680, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyFloat_FromDouble((__pyx_v_offer->final_quantity * __pyx_v_offer->price)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 680, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_9 = NULL; + __pyx_t_8 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + __pyx_t_8 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_v_offer->currency, __pyx_t_1, __pyx_t_3}; + __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 680, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_v_offer->currency, __pyx_t_1, __pyx_t_3}; + __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 680, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + { + __pyx_t_7 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 680, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_9) { + __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_9); __pyx_t_9 = NULL; + } + __Pyx_INCREF(__pyx_v_offer->currency); + __Pyx_GIVEREF(__pyx_v_offer->currency); + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_8, __pyx_v_offer->currency); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_8, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_8, __pyx_t_3); + __pyx_t_1 = 0; + __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 680, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_L3:; - /* "trade.pyx":680 - * self._haves[offer.good] += offer.final_quantity - * self._haves['money'] += (offer.quantity - offer.final_quantity) * offer.price + /* "trade.pyx":681 + * self._inventory.haves[offer.good] += offer.final_quantity + * self._inventory.commit(offer.currency, offer.quantity * offer.price, offer.final_quantity * offer.price) * offer.status = "accepted" # <<<<<<<<<<<<<< * offer.status_round = self.round * del self.given_offers[offer.id] @@ -9853,32 +9960,32 @@ static PyObject *__pyx_pf_5trade_5Trade_32_receive_accept(struct __pyx_obj_5trad __Pyx_DECREF(__pyx_v_offer->status); __pyx_v_offer->status = __pyx_n_s_accepted; - /* "trade.pyx":681 - * self._haves['money'] += (offer.quantity - offer.final_quantity) * offer.price + /* "trade.pyx":682 + * self._inventory.commit(offer.currency, offer.quantity * offer.price, offer.final_quantity * offer.price) * offer.status = "accepted" * offer.status_round = self.round # <<<<<<<<<<<<<< * del self.given_offers[offer.id] * return offer */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_round); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 681, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 681, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_offer->status_round = __pyx_t_9; + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_round); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 682, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_6); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 682, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_v_offer->status_round = __pyx_t_8; - /* "trade.pyx":682 + /* "trade.pyx":683 * offer.status = "accepted" * offer.status_round = self.round * del self.given_offers[offer.id] # <<<<<<<<<<<<<< * return offer * */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_given_offers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 682, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (unlikely(PyObject_DelItem(__pyx_t_3, __pyx_v_offer->id) < 0)) __PYX_ERR(0, 682, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_given_offers); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 683, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (unlikely(PyObject_DelItem(__pyx_t_6, __pyx_v_offer->id) < 0)) __PYX_ERR(0, 683, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "trade.pyx":683 + /* "trade.pyx":684 * offer.status_round = self.round * del self.given_offers[offer.id] * return offer # <<<<<<<<<<<<<< @@ -9890,7 +9997,7 @@ static PyObject *__pyx_pf_5trade_5Trade_32_receive_accept(struct __pyx_obj_5trad __pyx_r = ((PyObject *)__pyx_v_offer); goto __pyx_L0; - /* "trade.pyx":667 + /* "trade.pyx":668 * self._trade_log[(offer.good, '%s_%i' % (offer.receiver_group, offer.receiver_id), self.name_without_colon, offer.price)] += offer.quantity * * def _receive_accept(self, offer_id_final_quantity): # <<<<<<<<<<<<<< @@ -9905,7 +10012,8 @@ static PyObject *__pyx_pf_5trade_5Trade_32_receive_accept(struct __pyx_obj_5trad __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("trade.Trade._receive_accept", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -9915,7 +10023,7 @@ static PyObject *__pyx_pf_5trade_5Trade_32_receive_accept(struct __pyx_obj_5trad return __pyx_r; } -/* "trade.pyx":685 +/* "trade.pyx":686 * return offer * * def _log_receive_accept_group(self, offer): # <<<<<<<<<<<<<< @@ -9948,37 +10056,37 @@ static PyObject *__pyx_pf_5trade_5Trade_34_log_receive_accept_group(struct __pyx PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("_log_receive_accept_group", 0); - /* "trade.pyx":686 + /* "trade.pyx":687 * * def _log_receive_accept_group(self, offer): * if offer.sell: # <<<<<<<<<<<<<< * self._trade_log[(offer.good, self.group, offer.receiver_group, offer.price)] += offer.final_quantity * else: */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_sell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 686, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_sell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 687, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 686, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 687, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "trade.pyx":687 + /* "trade.pyx":688 * def _log_receive_accept_group(self, offer): * if offer.sell: * self._trade_log[(offer.good, self.group, offer.receiver_group, offer.price)] += offer.final_quantity # <<<<<<<<<<<<<< * else: * self._trade_log[(offer.good, offer.receiver_group, self.group, offer.price)] += offer.final_quantity */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 687, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 687, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 687, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_group); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 687, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_group); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 687, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 687, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); @@ -9992,20 +10100,20 @@ static PyObject *__pyx_pf_5trade_5Trade_34_log_receive_accept_group(struct __pyx __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; - __pyx_t_6 = PyObject_GetItem(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 687, __pyx_L1_error) + __pyx_t_6 = PyObject_GetItem(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_final_quantity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 687, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_final_quantity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 687, __pyx_L1_error) + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_7, __pyx_t_4) < 0)) __PYX_ERR(0, 687, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_7, __pyx_t_4) < 0)) __PYX_ERR(0, 688, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":686 + /* "trade.pyx":687 * * def _log_receive_accept_group(self, offer): * if offer.sell: # <<<<<<<<<<<<<< @@ -10015,7 +10123,7 @@ static PyObject *__pyx_pf_5trade_5Trade_34_log_receive_accept_group(struct __pyx goto __pyx_L3; } - /* "trade.pyx":689 + /* "trade.pyx":690 * self._trade_log[(offer.good, self.group, offer.receiver_group, offer.price)] += offer.final_quantity * else: * self._trade_log[(offer.good, offer.receiver_group, self.group, offer.price)] += offer.final_quantity # <<<<<<<<<<<<<< @@ -10023,17 +10131,17 @@ static PyObject *__pyx_pf_5trade_5Trade_34_log_receive_accept_group(struct __pyx * def _log_receive_accept_agent(self, offer): */ /*else*/ { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 689, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 689, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 689, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_group); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 689, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_group); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 689, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 689, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); @@ -10047,22 +10155,22 @@ static PyObject *__pyx_pf_5trade_5Trade_34_log_receive_accept_group(struct __pyx __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; - __pyx_t_6 = PyObject_GetItem(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 689, __pyx_L1_error) + __pyx_t_6 = PyObject_GetItem(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_final_quantity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 689, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_final_quantity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 689, __pyx_L1_error) + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_3, __pyx_t_4) < 0)) __PYX_ERR(0, 689, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_3, __pyx_t_4) < 0)) __PYX_ERR(0, 690, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L3:; - /* "trade.pyx":685 + /* "trade.pyx":686 * return offer * * def _log_receive_accept_group(self, offer): # <<<<<<<<<<<<<< @@ -10088,7 +10196,7 @@ static PyObject *__pyx_pf_5trade_5Trade_34_log_receive_accept_group(struct __pyx return __pyx_r; } -/* "trade.pyx":691 +/* "trade.pyx":692 * self._trade_log[(offer.good, offer.receiver_group, self.group, offer.price)] += offer.final_quantity * * def _log_receive_accept_agent(self, offer): # <<<<<<<<<<<<<< @@ -10121,37 +10229,37 @@ static PyObject *__pyx_pf_5trade_5Trade_36_log_receive_accept_agent(struct __pyx PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("_log_receive_accept_agent", 0); - /* "trade.pyx":692 + /* "trade.pyx":693 * * def _log_receive_accept_agent(self, offer): * if offer.sell: # <<<<<<<<<<<<<< * self._trade_log[(offer.good, self.name_without_colon, '%s_%i' % (offer.receiver_group, offer.receiver_id), offer.price)] += offer.final_quantity * else: */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_sell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 692, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_sell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 693, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 692, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 693, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "trade.pyx":693 + /* "trade.pyx":694 * def _log_receive_accept_agent(self, offer): * if offer.sell: * self._trade_log[(offer.good, self.name_without_colon, '%s_%i' % (offer.receiver_group, offer.receiver_id), offer.price)] += offer.final_quantity # <<<<<<<<<<<<<< * else: * self._trade_log[(offer.good, '%s_%i' % (offer.receiver_group, offer.receiver_id), self.name_without_colon, offer.price)] += offer.final_quantity */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 693, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 693, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name_without_colon); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 693, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name_without_colon); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_group); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 693, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_group); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 693, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 693, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); @@ -10159,12 +10267,12 @@ static PyObject *__pyx_pf_5trade_5Trade_36_log_receive_accept_agent(struct __pyx PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6); __pyx_t_5 = 0; __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_s__i, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 693, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_s__i, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 693, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 693, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); @@ -10178,20 +10286,20 @@ static PyObject *__pyx_pf_5trade_5Trade_36_log_receive_accept_agent(struct __pyx __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; - __pyx_t_7 = PyObject_GetItem(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 693, __pyx_L1_error) + __pyx_t_7 = PyObject_GetItem(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_final_quantity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 693, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_final_quantity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 693, __pyx_L1_error) + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_5, __pyx_t_4) < 0)) __PYX_ERR(0, 693, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_5, __pyx_t_4) < 0)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":692 + /* "trade.pyx":693 * * def _log_receive_accept_agent(self, offer): * if offer.sell: # <<<<<<<<<<<<<< @@ -10201,7 +10309,7 @@ static PyObject *__pyx_pf_5trade_5Trade_36_log_receive_accept_agent(struct __pyx goto __pyx_L3; } - /* "trade.pyx":695 + /* "trade.pyx":696 * self._trade_log[(offer.good, self.name_without_colon, '%s_%i' % (offer.receiver_group, offer.receiver_id), offer.price)] += offer.final_quantity * else: * self._trade_log[(offer.good, '%s_%i' % (offer.receiver_group, offer.receiver_id), self.name_without_colon, offer.price)] += offer.final_quantity # <<<<<<<<<<<<<< @@ -10209,15 +10317,15 @@ static PyObject *__pyx_pf_5trade_5Trade_36_log_receive_accept_agent(struct __pyx * def _receive_reject(self, offer_id): */ /*else*/ { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 695, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 695, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 695, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 695, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 695, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); @@ -10225,14 +10333,14 @@ static PyObject *__pyx_pf_5trade_5Trade_36_log_receive_accept_agent(struct __pyx PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6); __pyx_t_4 = 0; __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_s__i, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 695, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_s__i, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name_without_colon); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 695, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name_without_colon); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 695, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 695, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); @@ -10246,22 +10354,22 @@ static PyObject *__pyx_pf_5trade_5Trade_36_log_receive_accept_agent(struct __pyx __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_4 = 0; - __pyx_t_4 = PyObject_GetItem(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 695, __pyx_L1_error) + __pyx_t_4 = PyObject_GetItem(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_final_quantity); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 695, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_final_quantity); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 695, __pyx_L1_error) + __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_3, __pyx_t_6) < 0)) __PYX_ERR(0, 695, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_3, __pyx_t_6) < 0)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L3:; - /* "trade.pyx":691 + /* "trade.pyx":692 * self._trade_log[(offer.good, offer.receiver_group, self.group, offer.price)] += offer.final_quantity * * def _log_receive_accept_agent(self, offer): # <<<<<<<<<<<<<< @@ -10287,7 +10395,7 @@ static PyObject *__pyx_pf_5trade_5Trade_36_log_receive_accept_agent(struct __pyx return __pyx_r; } -/* "trade.pyx":697 +/* "trade.pyx":698 * self._trade_log[(offer.good, '%s_%i' % (offer.receiver_group, offer.receiver_id), self.name_without_colon, offer.price)] += offer.final_quantity * * def _receive_reject(self, offer_id): # <<<<<<<<<<<<<< @@ -10318,101 +10426,178 @@ static PyObject *__pyx_pf_5trade_5Trade_38_receive_reject(struct __pyx_obj_5trad int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; + int __pyx_t_6; PyObject *__pyx_t_7 = NULL; - int __pyx_t_8; __Pyx_RefNannySetupContext("_receive_reject", 0); - /* "trade.pyx":704 + /* "trade.pyx":705 * * """ * cdef Offer offer = self.given_offers[offer_id] # <<<<<<<<<<<<<< * if offer.sell: - * self._haves[offer.good] += offer.quantity + * self._inventory.rewind(offer.good, offer.quantity) */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_given_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 704, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_given_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 705, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_offer_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 704, __pyx_L1_error) + __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_offer_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 705, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5trade_Offer))))) __PYX_ERR(0, 704, __pyx_L1_error) + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5trade_Offer))))) __PYX_ERR(0, 705, __pyx_L1_error) __pyx_v_offer = ((struct __pyx_obj_5trade_Offer *)__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":705 + /* "trade.pyx":706 * """ * cdef Offer offer = self.given_offers[offer_id] * if offer.sell: # <<<<<<<<<<<<<< - * self._haves[offer.good] += offer.quantity + * self._inventory.rewind(offer.good, offer.quantity) * else: */ __pyx_t_3 = (__pyx_v_offer->sell != 0); if (__pyx_t_3) { - /* "trade.pyx":706 + /* "trade.pyx":707 * cdef Offer offer = self.given_offers[offer_id] * if offer.sell: - * self._haves[offer.good] += offer.quantity # <<<<<<<<<<<<<< + * self._inventory.rewind(offer.good, offer.quantity) # <<<<<<<<<<<<<< * else: - * self._haves[offer.currency] += offer.quantity * offer.price + * self._inventory.rewind(offer.currency, offer.quantity * offer.price) */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 706, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_v_offer->good); - __pyx_t_1 = __pyx_v_offer->good; - __pyx_t_4 = PyObject_GetItem(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 706, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 707, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_rewind); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 707, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyFloat_FromDouble(__pyx_v_offer->quantity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 706, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 706, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_2, __pyx_t_1, __pyx_t_6) < 0)) __PYX_ERR(0, 706, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_offer->quantity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 707, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = NULL; + __pyx_t_6 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_6 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_offer->good, __pyx_t_1}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 707, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_offer->good, __pyx_t_1}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 707, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + { + __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 707, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_5) { + __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; + } + __Pyx_INCREF(__pyx_v_offer->good); + __Pyx_GIVEREF(__pyx_v_offer->good); + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_offer->good); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 707, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":705 + /* "trade.pyx":706 * """ * cdef Offer offer = self.given_offers[offer_id] * if offer.sell: # <<<<<<<<<<<<<< - * self._haves[offer.good] += offer.quantity + * self._inventory.rewind(offer.good, offer.quantity) * else: */ goto __pyx_L3; } - /* "trade.pyx":708 - * self._haves[offer.good] += offer.quantity + /* "trade.pyx":709 + * self._inventory.rewind(offer.good, offer.quantity) * else: - * self._haves[offer.currency] += offer.quantity * offer.price # <<<<<<<<<<<<<< + * self._inventory.rewind(offer.currency, offer.quantity * offer.price) # <<<<<<<<<<<<<< * offer.status = "rejected" * offer.status_round = self.round */ /*else*/ { - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 708, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_v_offer->currency); - __pyx_t_7 = __pyx_v_offer->currency; - __pyx_t_1 = PyObject_GetItem(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 708, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyFloat_FromDouble((__pyx_v_offer->quantity * __pyx_v_offer->price)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 708, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 708, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_2, __pyx_t_7, __pyx_t_5) < 0)) __PYX_ERR(0, 708, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 709, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_rewind); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 709, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyFloat_FromDouble((__pyx_v_offer->quantity * __pyx_v_offer->price)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 709, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = NULL; + __pyx_t_6 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_1)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + __pyx_t_6 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_7)) { + PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_offer->currency, __pyx_t_4}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 709, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { + PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_offer->currency, __pyx_t_4}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 709, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + { + __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 709, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + if (__pyx_t_1) { + __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL; + } + __Pyx_INCREF(__pyx_v_offer->currency); + __Pyx_GIVEREF(__pyx_v_offer->currency); + PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_v_offer->currency); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 709, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_L3:; - /* "trade.pyx":709 + /* "trade.pyx":710 * else: - * self._haves[offer.currency] += offer.quantity * offer.price + * self._inventory.rewind(offer.currency, offer.quantity * offer.price) * offer.status = "rejected" # <<<<<<<<<<<<<< * offer.status_round = self.round * offer.final_quantity = 0 @@ -10423,20 +10608,20 @@ static PyObject *__pyx_pf_5trade_5Trade_38_receive_reject(struct __pyx_obj_5trad __Pyx_DECREF(__pyx_v_offer->status); __pyx_v_offer->status = __pyx_n_s_rejected; - /* "trade.pyx":710 - * self._haves[offer.currency] += offer.quantity * offer.price + /* "trade.pyx":711 + * self._inventory.rewind(offer.currency, offer.quantity * offer.price) * offer.status = "rejected" * offer.status_round = self.round # <<<<<<<<<<<<<< * offer.final_quantity = 0 * del self.given_offers[offer_id] */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_round); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 710, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_round); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 711, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 710, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 711, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_offer->status_round = __pyx_t_8; + __pyx_v_offer->status_round = __pyx_t_6; - /* "trade.pyx":711 + /* "trade.pyx":712 * offer.status = "rejected" * offer.status_round = self.round * offer.final_quantity = 0 # <<<<<<<<<<<<<< @@ -10445,19 +10630,19 @@ static PyObject *__pyx_pf_5trade_5Trade_38_receive_reject(struct __pyx_obj_5trad */ __pyx_v_offer->final_quantity = 0.0; - /* "trade.pyx":712 + /* "trade.pyx":713 * offer.status_round = self.round * offer.final_quantity = 0 * del self.given_offers[offer_id] # <<<<<<<<<<<<<< * * def _delete_given_offer(self, offer_id): */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_given_offers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 712, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_given_offers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 713, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (unlikely(PyObject_DelItem(__pyx_t_2, __pyx_v_offer_id) < 0)) __PYX_ERR(0, 712, __pyx_L1_error) + if (unlikely(PyObject_DelItem(__pyx_t_2, __pyx_v_offer_id) < 0)) __PYX_ERR(0, 713, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":697 + /* "trade.pyx":698 * self._trade_log[(offer.good, '%s_%i' % (offer.receiver_group, offer.receiver_id), self.name_without_colon, offer.price)] += offer.final_quantity * * def _receive_reject(self, offer_id): # <<<<<<<<<<<<<< @@ -10473,7 +10658,6 @@ static PyObject *__pyx_pf_5trade_5Trade_38_receive_reject(struct __pyx_obj_5trad __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("trade.Trade._receive_reject", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; @@ -10484,7 +10668,7 @@ static PyObject *__pyx_pf_5trade_5Trade_38_receive_reject(struct __pyx_obj_5trad return __pyx_r; } -/* "trade.pyx":714 +/* "trade.pyx":715 * del self.given_offers[offer_id] * * def _delete_given_offer(self, offer_id): # <<<<<<<<<<<<<< @@ -10514,20 +10698,20 @@ static PyObject *__pyx_pf_5trade_5Trade_40_delete_given_offer(struct __pyx_obj_5 PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; - PyObject *__pyx_t_6 = NULL; + int __pyx_t_6; PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("_delete_given_offer", 0); - /* "trade.pyx":715 + /* "trade.pyx":716 * * def _delete_given_offer(self, offer_id): * cdef Offer offer = self.given_offers.pop(offer_id) # <<<<<<<<<<<<<< * if offer.sell: - * self._haves[offer.good] += offer.quantity + * self._inventory.rewind(offer.good, offer.quantity) */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_given_offers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 715, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_given_offers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 716, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_pop); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 715, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_pop); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 716, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; @@ -10541,13 +10725,13 @@ static PyObject *__pyx_pf_5trade_5Trade_40_delete_given_offer(struct __pyx_obj_5 } } if (!__pyx_t_2) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_offer_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 715, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_offer_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 716, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_offer_id}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 715, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 716, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else @@ -10555,100 +10739,178 @@ static PyObject *__pyx_pf_5trade_5Trade_40_delete_given_offer(struct __pyx_obj_5 #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_offer_id}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 715, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 716, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { - __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 715, __pyx_L1_error) + __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 716, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL; __Pyx_INCREF(__pyx_v_offer_id); __Pyx_GIVEREF(__pyx_v_offer_id); PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_offer_id); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 715, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 716, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5trade_Offer))))) __PYX_ERR(0, 715, __pyx_L1_error) + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5trade_Offer))))) __PYX_ERR(0, 716, __pyx_L1_error) __pyx_v_offer = ((struct __pyx_obj_5trade_Offer *)__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":716 + /* "trade.pyx":717 * def _delete_given_offer(self, offer_id): * cdef Offer offer = self.given_offers.pop(offer_id) * if offer.sell: # <<<<<<<<<<<<<< - * self._haves[offer.good] += offer.quantity + * self._inventory.rewind(offer.good, offer.quantity) * else: */ __pyx_t_5 = (__pyx_v_offer->sell != 0); if (__pyx_t_5) { - /* "trade.pyx":717 + /* "trade.pyx":718 * cdef Offer offer = self.given_offers.pop(offer_id) * if offer.sell: - * self._haves[offer.good] += offer.quantity # <<<<<<<<<<<<<< + * self._inventory.rewind(offer.good, offer.quantity) # <<<<<<<<<<<<<< * else: - * self._haves[offer.currency] += offer.quantity * offer.price + * self._inventory.rewind(offer.currency, offer.quantity * offer.price) */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 717, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_v_offer->good); - __pyx_t_3 = __pyx_v_offer->good; - __pyx_t_4 = PyObject_GetItem(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 717, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 718, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_rewind); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 718, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_offer->quantity); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 717, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 717, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_3, __pyx_t_6) < 0)) __PYX_ERR(0, 717, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_offer->quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 718, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = NULL; + __pyx_t_6 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_2)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_6 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_offer->good, __pyx_t_3}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 718, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_offer->good, __pyx_t_3}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 718, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + #endif + { + __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 718, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_2) { + __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __pyx_t_2 = NULL; + } + __Pyx_INCREF(__pyx_v_offer->good); + __Pyx_GIVEREF(__pyx_v_offer->good); + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_offer->good); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 718, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":716 + /* "trade.pyx":717 * def _delete_given_offer(self, offer_id): * cdef Offer offer = self.given_offers.pop(offer_id) * if offer.sell: # <<<<<<<<<<<<<< - * self._haves[offer.good] += offer.quantity + * self._inventory.rewind(offer.good, offer.quantity) * else: */ goto __pyx_L3; } - - /* "trade.pyx":719 - * self._haves[offer.good] += offer.quantity - * else: - * self._haves[offer.currency] += offer.quantity * offer.price # <<<<<<<<<<<<<< - * - * def give(self, receiver, good, double quantity, double epsilon=epsilon): - */ - /*else*/ { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 719, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_v_offer->currency); - __pyx_t_7 = __pyx_v_offer->currency; - __pyx_t_3 = PyObject_GetItem(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 719, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = PyFloat_FromDouble((__pyx_v_offer->quantity * __pyx_v_offer->price)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 719, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 719, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_7, __pyx_t_2) < 0)) __PYX_ERR(0, 719, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "trade.pyx":720 + * self._inventory.rewind(offer.good, offer.quantity) + * else: + * self._inventory.rewind(offer.currency, offer.quantity * offer.price) # <<<<<<<<<<<<<< + * + * def give(self, receiver, good, double quantity, double epsilon=epsilon): + */ + /*else*/ { + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 720, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_rewind); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 720, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyFloat_FromDouble((__pyx_v_offer->quantity * __pyx_v_offer->price)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 720, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = NULL; + __pyx_t_6 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + __pyx_t_6 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_7)) { + PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_offer->currency, __pyx_t_4}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 720, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { + PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_offer->currency, __pyx_t_4}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 720, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + { + __pyx_t_2 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 720, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (__pyx_t_3) { + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL; + } + __Pyx_INCREF(__pyx_v_offer->currency); + __Pyx_GIVEREF(__pyx_v_offer->currency); + PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_6, __pyx_v_offer->currency); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_6, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 720, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L3:; - /* "trade.pyx":714 + /* "trade.pyx":715 * del self.given_offers[offer_id] * * def _delete_given_offer(self, offer_id): # <<<<<<<<<<<<<< @@ -10664,7 +10926,6 @@ static PyObject *__pyx_pf_5trade_5Trade_40_delete_given_offer(struct __pyx_obj_5 __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("trade.Trade._delete_given_offer", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; @@ -10675,8 +10936,8 @@ static PyObject *__pyx_pf_5trade_5Trade_40_delete_given_offer(struct __pyx_obj_5 return __pyx_r; } -/* "trade.pyx":721 - * self._haves[offer.currency] += offer.quantity * offer.price +/* "trade.pyx":722 + * self._inventory.rewind(offer.currency, offer.quantity * offer.price) * * def give(self, receiver, good, double quantity, double epsilon=epsilon): # <<<<<<<<<<<<<< * """ gives a good to another agent @@ -10716,12 +10977,12 @@ static PyObject *__pyx_pw_5trade_5Trade_43give(PyObject *__pyx_v_self, PyObject case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_good)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("give", 0, 3, 4, 1); __PYX_ERR(0, 721, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("give", 0, 3, 4, 1); __PYX_ERR(0, 722, __pyx_L3_error) } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_quantity)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("give", 0, 3, 4, 2); __PYX_ERR(0, 721, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("give", 0, 3, 4, 2); __PYX_ERR(0, 722, __pyx_L3_error) } case 3: if (kw_args > 0) { @@ -10730,7 +10991,7 @@ static PyObject *__pyx_pw_5trade_5Trade_43give(PyObject *__pyx_v_self, PyObject } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "give") < 0)) __PYX_ERR(0, 721, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "give") < 0)) __PYX_ERR(0, 722, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -10744,16 +11005,16 @@ static PyObject *__pyx_pw_5trade_5Trade_43give(PyObject *__pyx_v_self, PyObject } __pyx_v_receiver = values[0]; __pyx_v_good = values[1]; - __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 721, __pyx_L3_error) + __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 722, __pyx_L3_error) if (values[3]) { - __pyx_v_epsilon = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_epsilon == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 721, __pyx_L3_error) + __pyx_v_epsilon = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_epsilon == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 722, __pyx_L3_error) } else { __pyx_v_epsilon = __pyx_k__4; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("give", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 721, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("give", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 722, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade.give", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -10784,7 +11045,7 @@ static PyObject *__pyx_pf_5trade_5Trade_42give(struct __pyx_obj_5trade_Trade *__ PyObject *__pyx_t_12 = NULL; __Pyx_RefNannySetupContext("give", 0); - /* "trade.pyx":751 + /* "trade.pyx":752 * """ * cdef double available * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) # <<<<<<<<<<<<<< @@ -10794,11 +11055,11 @@ static PyObject *__pyx_pf_5trade_5Trade_42give(struct __pyx_obj_5trade_Trade *__ #ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_quantity > (-__pyx_v_epsilon)) != 0))) { - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 751, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 752, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 751, __pyx_L1_error) + __pyx_t_2 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 752, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 751, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 752, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); @@ -10806,63 +11067,63 @@ static PyObject *__pyx_pf_5trade_5Trade_42give(struct __pyx_obj_5trade_Trade *__ PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_quantity_30f_is_smaller_than_0_e, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 751, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_quantity_30f_is_smaller_than_0_e, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 752, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 751, __pyx_L1_error) + __PYX_ERR(0, 752, __pyx_L1_error) } } #endif - /* "trade.pyx":752 + /* "trade.pyx":753 * cdef double available * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: # <<<<<<<<<<<<<< * quantity = 0 - * available = self._haves[good] + * available = self._inventory[good] */ __pyx_t_4 = ((__pyx_v_quantity < 0.0) != 0); if (__pyx_t_4) { - /* "trade.pyx":753 + /* "trade.pyx":754 * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: * quantity = 0 # <<<<<<<<<<<<<< - * available = self._haves[good] + * available = self._inventory[good] * if quantity > available + epsilon + epsilon * max(quantity, available): */ __pyx_v_quantity = 0.0; - /* "trade.pyx":752 + /* "trade.pyx":753 * cdef double available * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: # <<<<<<<<<<<<<< * quantity = 0 - * available = self._haves[good] + * available = self._inventory[good] */ } - /* "trade.pyx":754 + /* "trade.pyx":755 * if quantity < 0: * quantity = 0 - * available = self._haves[good] # <<<<<<<<<<<<<< + * available = self._inventory[good] # <<<<<<<<<<<<<< * if quantity > available + epsilon + epsilon * max(quantity, available): * raise NotEnoughGoods(self.name, good, quantity - available) */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 754, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 755, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 754, __pyx_L1_error) + __pyx_t_3 = PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 755, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 754, __pyx_L1_error) + __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 755, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_available = __pyx_t_5; - /* "trade.pyx":755 + /* "trade.pyx":756 * quantity = 0 - * available = self._haves[good] + * available = self._inventory[good] * if quantity > available + epsilon + epsilon * max(quantity, available): # <<<<<<<<<<<<<< * raise NotEnoughGoods(self.name, good, quantity - available) * if quantity > available: @@ -10877,18 +11138,18 @@ static PyObject *__pyx_pf_5trade_5Trade_42give(struct __pyx_obj_5trade_Trade *__ __pyx_t_4 = ((__pyx_v_quantity > ((__pyx_v_available + __pyx_v_epsilon) + (__pyx_v_epsilon * __pyx_t_7))) != 0); if (__pyx_t_4) { - /* "trade.pyx":756 - * available = self._haves[good] + /* "trade.pyx":757 + * available = self._inventory[good] * if quantity > available + epsilon + epsilon * max(quantity, available): * raise NotEnoughGoods(self.name, good, quantity - available) # <<<<<<<<<<<<<< * if quantity > available: * quantity = available */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_NotEnoughGoods); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 756, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_NotEnoughGoods); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 756, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyFloat_FromDouble((__pyx_v_quantity - __pyx_v_available)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 756, __pyx_L1_error) + __pyx_t_8 = PyFloat_FromDouble((__pyx_v_quantity - __pyx_v_available)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = NULL; __pyx_t_10 = 0; @@ -10905,7 +11166,7 @@ static PyObject *__pyx_pf_5trade_5Trade_42give(struct __pyx_obj_5trade_Trade *__ #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_1, __pyx_v_good, __pyx_t_8}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 756, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 757, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -10915,7 +11176,7 @@ static PyObject *__pyx_pf_5trade_5Trade_42give(struct __pyx_obj_5trade_Trade *__ #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_1, __pyx_v_good, __pyx_t_8}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 756, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 757, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -10923,7 +11184,7 @@ static PyObject *__pyx_pf_5trade_5Trade_42give(struct __pyx_obj_5trade_Trade *__ } else #endif { - __pyx_t_11 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 756, __pyx_L1_error) + __pyx_t_11 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL; @@ -10937,92 +11198,95 @@ static PyObject *__pyx_pf_5trade_5Trade_42give(struct __pyx_obj_5trade_Trade *__ PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_t_8); __pyx_t_1 = 0; __pyx_t_8 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 756, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 756, __pyx_L1_error) + __PYX_ERR(0, 757, __pyx_L1_error) - /* "trade.pyx":755 + /* "trade.pyx":756 * quantity = 0 - * available = self._haves[good] + * available = self._inventory[good] * if quantity > available + epsilon + epsilon * max(quantity, available): # <<<<<<<<<<<<<< * raise NotEnoughGoods(self.name, good, quantity - available) * if quantity > available: */ } - /* "trade.pyx":757 + /* "trade.pyx":758 * if quantity > available + epsilon + epsilon * max(quantity, available): * raise NotEnoughGoods(self.name, good, quantity - available) * if quantity > available: # <<<<<<<<<<<<<< * quantity = available - * self._haves[good] -= quantity + * self._inventory.haves[good] -= quantity */ __pyx_t_4 = ((__pyx_v_quantity > __pyx_v_available) != 0); if (__pyx_t_4) { - /* "trade.pyx":758 + /* "trade.pyx":759 * raise NotEnoughGoods(self.name, good, quantity - available) * if quantity > available: * quantity = available # <<<<<<<<<<<<<< - * self._haves[good] -= quantity + * self._inventory.haves[good] -= quantity * self._send(receiver[0], receiver[1], '_g', [good, quantity]) */ __pyx_v_quantity = __pyx_v_available; - /* "trade.pyx":757 + /* "trade.pyx":758 * if quantity > available + epsilon + epsilon * max(quantity, available): * raise NotEnoughGoods(self.name, good, quantity - available) * if quantity > available: # <<<<<<<<<<<<<< * quantity = available - * self._haves[good] -= quantity + * self._inventory.haves[good] -= quantity */ } - /* "trade.pyx":759 + /* "trade.pyx":760 * if quantity > available: * quantity = available - * self._haves[good] -= quantity # <<<<<<<<<<<<<< + * self._inventory.haves[good] -= quantity # <<<<<<<<<<<<<< * self._send(receiver[0], receiver[1], '_g', [good, quantity]) * return {good: quantity} */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 759, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 760, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_haves); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 760, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_v_good); - __pyx_t_2 = __pyx_v_good; - __pyx_t_11 = PyObject_GetItem(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 759, __pyx_L1_error) + __pyx_t_3 = __pyx_v_good; + __pyx_t_11 = PyObject_GetItem(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 760, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_8 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 759, __pyx_L1_error) + __pyx_t_8 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 760, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - __pyx_t_1 = PyNumber_InPlaceSubtract(__pyx_t_11, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 759, __pyx_L1_error) + __pyx_t_1 = PyNumber_InPlaceSubtract(__pyx_t_11, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 760, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_3, __pyx_t_2, __pyx_t_1) < 0)) __PYX_ERR(0, 759, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_2, __pyx_t_3, __pyx_t_1) < 0)) __PYX_ERR(0, 760, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":760 + /* "trade.pyx":761 * quantity = available - * self._haves[good] -= quantity + * self._inventory.haves[good] -= quantity * self._send(receiver[0], receiver[1], '_g', [good, quantity]) # <<<<<<<<<<<<<< * return {good: quantity} * */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 760, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_receiver, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 760, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 761, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_receiver, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 761, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_receiver, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 760, __pyx_L1_error) + __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_receiver, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 761, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - __pyx_t_11 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 760, __pyx_L1_error) + __pyx_t_11 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 761, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_9 = PyList_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 760, __pyx_L1_error) + __pyx_t_9 = PyList_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 761, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_v_good); __Pyx_GIVEREF(__pyx_v_good); @@ -11032,40 +11296,40 @@ static PyObject *__pyx_pf_5trade_5Trade_42give(struct __pyx_obj_5trade_Trade *__ __pyx_t_11 = 0; __pyx_t_11 = NULL; __pyx_t_10 = 0; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_2); + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_11)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); + __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { + if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[5] = {__pyx_t_11, __pyx_t_1, __pyx_t_8, __pyx_n_s_g, __pyx_t_9}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 760, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 761, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_GOTREF(__pyx_t_3); + __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else #endif #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[5] = {__pyx_t_11, __pyx_t_1, __pyx_t_8, __pyx_n_s_g, __pyx_t_9}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 760, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 761, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_GOTREF(__pyx_t_3); + __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else #endif { - __pyx_t_12 = PyTuple_New(4+__pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 760, __pyx_L1_error) + __pyx_t_12 = PyTuple_New(4+__pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 761, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); if (__pyx_t_11) { __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL; @@ -11082,33 +11346,33 @@ static PyObject *__pyx_pf_5trade_5Trade_42give(struct __pyx_obj_5trade_Trade *__ __pyx_t_1 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 760, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_12, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 761, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":761 - * self._haves[good] -= quantity + /* "trade.pyx":762 + * self._inventory.haves[good] -= quantity * self._send(receiver[0], receiver[1], '_g', [good, quantity]) * return {good: quantity} # <<<<<<<<<<<<<< * * def take(self, receiver, good, double quantity, double epsilon=epsilon): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 761, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 761, __pyx_L1_error) + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 762, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_t_3, __pyx_v_good, __pyx_t_2) < 0) __PYX_ERR(0, 761, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 762, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(__pyx_t_2, __pyx_v_good, __pyx_t_3) < 0) __PYX_ERR(0, 762, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; goto __pyx_L0; - /* "trade.pyx":721 - * self._haves[offer.currency] += offer.quantity * offer.price + /* "trade.pyx":722 + * self._inventory.rewind(offer.currency, offer.quantity * offer.price) * * def give(self, receiver, good, double quantity, double epsilon=epsilon): # <<<<<<<<<<<<<< * """ gives a good to another agent @@ -11132,7 +11396,7 @@ static PyObject *__pyx_pf_5trade_5Trade_42give(struct __pyx_obj_5trade_Trade *__ return __pyx_r; } -/* "trade.pyx":763 +/* "trade.pyx":764 * return {good: quantity} * * def take(self, receiver, good, double quantity, double epsilon=epsilon): # <<<<<<<<<<<<<< @@ -11173,12 +11437,12 @@ static PyObject *__pyx_pw_5trade_5Trade_45take(PyObject *__pyx_v_self, PyObject case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_good)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("take", 0, 3, 4, 1); __PYX_ERR(0, 763, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("take", 0, 3, 4, 1); __PYX_ERR(0, 764, __pyx_L3_error) } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_quantity)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("take", 0, 3, 4, 2); __PYX_ERR(0, 763, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("take", 0, 3, 4, 2); __PYX_ERR(0, 764, __pyx_L3_error) } case 3: if (kw_args > 0) { @@ -11187,7 +11451,7 @@ static PyObject *__pyx_pw_5trade_5Trade_45take(PyObject *__pyx_v_self, PyObject } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "take") < 0)) __PYX_ERR(0, 763, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "take") < 0)) __PYX_ERR(0, 764, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -11201,16 +11465,16 @@ static PyObject *__pyx_pw_5trade_5Trade_45take(PyObject *__pyx_v_self, PyObject } __pyx_v_receiver = values[0]; __pyx_v_good = values[1]; - __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 763, __pyx_L3_error) + __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 764, __pyx_L3_error) if (values[3]) { - __pyx_v_epsilon = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_epsilon == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 763, __pyx_L3_error) + __pyx_v_epsilon = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_epsilon == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 764, __pyx_L3_error) } else { __pyx_v_epsilon = __pyx_k__5; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("take", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 763, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("take", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 764, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade.take", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -11232,20 +11496,20 @@ static PyObject *__pyx_pf_5trade_5Trade_44take(struct __pyx_obj_5trade_Trade *__ PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("take", 0); - /* "trade.pyx":787 + /* "trade.pyx":788 * floating point tolerance. See troubleshooting -- floating point problems * """ * self.buy(receiver[0], receiver[1], good=good, quantity=quantity, price=0, epsilon=epsilon) # <<<<<<<<<<<<<< * * */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_buy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 787, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_buy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_receiver, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 787, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_receiver, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_receiver, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 787, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_receiver, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 787, __pyx_L1_error) + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); @@ -11253,26 +11517,26 @@ static PyObject *__pyx_pf_5trade_5Trade_44take(struct __pyx_obj_5trade_Trade *__ PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); __pyx_t_2 = 0; __pyx_t_3 = 0; - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 787, __pyx_L1_error) + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_good, __pyx_v_good) < 0) __PYX_ERR(0, 787, __pyx_L1_error) - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 787, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_good, __pyx_v_good) < 0) __PYX_ERR(0, 788, __pyx_L1_error) + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_quantity, __pyx_t_2) < 0) __PYX_ERR(0, 787, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_quantity, __pyx_t_2) < 0) __PYX_ERR(0, 788, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_price, __pyx_int_0) < 0) __PYX_ERR(0, 787, __pyx_L1_error) - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_epsilon); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 787, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_price, __pyx_int_0) < 0) __PYX_ERR(0, 788, __pyx_L1_error) + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_epsilon); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_epsilon, __pyx_t_2) < 0) __PYX_ERR(0, 787, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_epsilon, __pyx_t_2) < 0) __PYX_ERR(0, 788, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 787, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":763 + /* "trade.pyx":764 * return {good: quantity} * * def take(self, receiver, good, double quantity, double epsilon=epsilon): # <<<<<<<<<<<<<< @@ -11296,7 +11560,7 @@ static PyObject *__pyx_pf_5trade_5Trade_44take(struct __pyx_obj_5trade_Trade *__ return __pyx_r; } -/* "trade.pyx":790 +/* "trade.pyx":791 * * * def _clearing__end_of_subround(self, incomming_messages): # <<<<<<<<<<<<<< @@ -11341,7 +11605,7 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py int __pyx_t_14; __Pyx_RefNannySetupContext("_clearing__end_of_subround", 0); - /* "trade.pyx":801 + /* "trade.pyx":802 * """ * cdef Offer offer * for typ, msg in incomming_messages: # <<<<<<<<<<<<<< @@ -11352,26 +11616,26 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py __pyx_t_1 = __pyx_v_incomming_messages; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = NULL; } else { - __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_incomming_messages); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 801, __pyx_L1_error) + __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_incomming_messages); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 802, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 801, __pyx_L1_error) + __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 802, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_3)) { if (likely(PyList_CheckExact(__pyx_t_1))) { if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 801, __pyx_L1_error) + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 802, __pyx_L1_error) #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 801, __pyx_L1_error) + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 802, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 801, __pyx_L1_error) + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 802, __pyx_L1_error) #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 801, __pyx_L1_error) + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 802, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } @@ -11381,7 +11645,7 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 801, __pyx_L1_error) + else __PYX_ERR(0, 802, __pyx_L1_error) } break; } @@ -11397,7 +11661,7 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 801, __pyx_L1_error) + __PYX_ERR(0, 802, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { @@ -11410,15 +11674,15 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); #else - __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 801, __pyx_L1_error) + __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 802, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 801, __pyx_L1_error) + __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 802, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); #endif __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { Py_ssize_t index = -1; - __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 801, __pyx_L1_error) + __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 802, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; @@ -11426,7 +11690,7 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py __Pyx_GOTREF(__pyx_t_5); index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 801, __pyx_L1_error) + if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 802, __pyx_L1_error) __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L6_unpacking_done; @@ -11434,7 +11698,7 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 801, __pyx_L1_error) + __PYX_ERR(0, 802, __pyx_L1_error) __pyx_L6_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_typ, __pyx_t_5); @@ -11442,38 +11706,38 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py __Pyx_XDECREF_SET(__pyx_v_msg, __pyx_t_6); __pyx_t_6 = 0; - /* "trade.pyx":802 + /* "trade.pyx":803 * cdef Offer offer * for typ, msg in incomming_messages: * if typ == '!b': # <<<<<<<<<<<<<< * self._open_offers_buy[msg.good][msg.id] = msg * elif typ == '!s': */ - __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_typ, __pyx_kp_s_b, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 802, __pyx_L1_error) + __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_typ, __pyx_kp_s_b, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 803, __pyx_L1_error) if (__pyx_t_9) { - /* "trade.pyx":803 + /* "trade.pyx":804 * for typ, msg in incomming_messages: * if typ == '!b': * self._open_offers_buy[msg.good][msg.id] = msg # <<<<<<<<<<<<<< * elif typ == '!s': * self._open_offers_sell[msg.good][msg.id] = msg */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 803, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 804, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_good); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 803, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_good); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 804, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = PyObject_GetItem(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 803, __pyx_L1_error) + __pyx_t_5 = PyObject_GetItem(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 804, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 803, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 804, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_t_6, __pyx_v_msg) < 0)) __PYX_ERR(0, 803, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_t_6, __pyx_v_msg) < 0)) __PYX_ERR(0, 804, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "trade.pyx":802 + /* "trade.pyx":803 * cdef Offer offer * for typ, msg in incomming_messages: * if typ == '!b': # <<<<<<<<<<<<<< @@ -11483,38 +11747,38 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py goto __pyx_L7; } - /* "trade.pyx":804 + /* "trade.pyx":805 * if typ == '!b': * self._open_offers_buy[msg.good][msg.id] = msg * elif typ == '!s': # <<<<<<<<<<<<<< * self._open_offers_sell[msg.good][msg.id] = msg * elif typ == '_p': */ - __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_typ, __pyx_kp_s_s, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 804, __pyx_L1_error) + __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_typ, __pyx_kp_s_s, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 805, __pyx_L1_error) if (__pyx_t_9) { - /* "trade.pyx":805 + /* "trade.pyx":806 * self._open_offers_buy[msg.good][msg.id] = msg * elif typ == '!s': * self._open_offers_sell[msg.good][msg.id] = msg # <<<<<<<<<<<<<< * elif typ == '_p': * offer = self._receive_accept(msg) */ - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 805, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 806, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_good); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 805, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_good); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 806, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyObject_GetItem(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 805, __pyx_L1_error) + __pyx_t_4 = PyObject_GetItem(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 806, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 805, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 806, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - if (unlikely(PyObject_SetItem(__pyx_t_4, __pyx_t_5, __pyx_v_msg) < 0)) __PYX_ERR(0, 805, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_4, __pyx_t_5, __pyx_v_msg) < 0)) __PYX_ERR(0, 806, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - /* "trade.pyx":804 + /* "trade.pyx":805 * if typ == '!b': * self._open_offers_buy[msg.good][msg.id] = msg * elif typ == '!s': # <<<<<<<<<<<<<< @@ -11524,24 +11788,24 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py goto __pyx_L7; } - /* "trade.pyx":806 + /* "trade.pyx":807 * elif typ == '!s': * self._open_offers_sell[msg.good][msg.id] = msg * elif typ == '_p': # <<<<<<<<<<<<<< * offer = self._receive_accept(msg) * if self.trade_logging == 2: */ - __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_typ, __pyx_n_s_p, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 806, __pyx_L1_error) + __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_typ, __pyx_n_s_p, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 807, __pyx_L1_error) if (__pyx_t_9) { - /* "trade.pyx":807 + /* "trade.pyx":808 * self._open_offers_sell[msg.good][msg.id] = msg * elif typ == '_p': * offer = self._receive_accept(msg) # <<<<<<<<<<<<<< * if self.trade_logging == 2: * self._log_receive_accept_group(offer) */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_receive_accept); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 807, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_receive_accept); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 808, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { @@ -11554,13 +11818,13 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py } } if (!__pyx_t_6) { - __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_msg); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 807, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_msg); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 808, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_msg}; - __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 807, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 808, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); } else @@ -11568,52 +11832,52 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_msg}; - __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 807, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 808, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif { - __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 807, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 808, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_INCREF(__pyx_v_msg); __Pyx_GIVEREF(__pyx_v_msg); PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_msg); - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 807, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 808, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5trade_Offer))))) __PYX_ERR(0, 807, __pyx_L1_error) + if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5trade_Offer))))) __PYX_ERR(0, 808, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_offer, ((struct __pyx_obj_5trade_Offer *)__pyx_t_5)); __pyx_t_5 = 0; - /* "trade.pyx":808 + /* "trade.pyx":809 * elif typ == '_p': * offer = self._receive_accept(msg) * if self.trade_logging == 2: # <<<<<<<<<<<<<< * self._log_receive_accept_group(offer) * elif self.trade_logging == 1: */ - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trade_logging); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 808, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trade_logging); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 809, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = __Pyx_PyInt_EqObjC(__pyx_t_5, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 808, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_EqObjC(__pyx_t_5, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 809, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 808, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 809, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_9) { - /* "trade.pyx":809 + /* "trade.pyx":810 * offer = self._receive_accept(msg) * if self.trade_logging == 2: * self._log_receive_accept_group(offer) # <<<<<<<<<<<<<< * elif self.trade_logging == 1: * self._log_receive_accept_agent(offer) */ - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_log_receive_accept_group); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 809, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_log_receive_accept_group); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 810, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { @@ -11626,13 +11890,13 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py } } if (!__pyx_t_7) { - __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_offer)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 809, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_offer)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 810, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_7, ((PyObject *)__pyx_v_offer)}; - __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 809, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 810, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_4); } else @@ -11640,19 +11904,19 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_7, ((PyObject *)__pyx_v_offer)}; - __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 809, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 810, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_4); } else #endif { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 809, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 810, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = NULL; __Pyx_INCREF(((PyObject *)__pyx_v_offer)); __Pyx_GIVEREF(((PyObject *)__pyx_v_offer)); PyTuple_SET_ITEM(__pyx_t_6, 0+1, ((PyObject *)__pyx_v_offer)); - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 809, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 810, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } @@ -11660,7 +11924,7 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "trade.pyx":808 + /* "trade.pyx":809 * elif typ == '_p': * offer = self._receive_accept(msg) * if self.trade_logging == 2: # <<<<<<<<<<<<<< @@ -11670,30 +11934,30 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py goto __pyx_L8; } - /* "trade.pyx":810 + /* "trade.pyx":811 * if self.trade_logging == 2: * self._log_receive_accept_group(offer) * elif self.trade_logging == 1: # <<<<<<<<<<<<<< * self._log_receive_accept_agent(offer) * elif typ == '_r': */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trade_logging); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 810, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trade_logging); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 811, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyInt_EqObjC(__pyx_t_4, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 810, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyInt_EqObjC(__pyx_t_4, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 811, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 810, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 811, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_9) { - /* "trade.pyx":811 + /* "trade.pyx":812 * self._log_receive_accept_group(offer) * elif self.trade_logging == 1: * self._log_receive_accept_agent(offer) # <<<<<<<<<<<<<< * elif typ == '_r': * self._receive_reject(msg) */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_log_receive_accept_agent); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 811, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_log_receive_accept_agent); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 812, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { @@ -11706,13 +11970,13 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py } } if (!__pyx_t_6) { - __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_offer)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 811, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_offer)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 812, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_6, ((PyObject *)__pyx_v_offer)}; - __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 811, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 812, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); } else @@ -11720,19 +11984,19 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_6, ((PyObject *)__pyx_v_offer)}; - __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 811, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 812, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif { - __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 811, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 812, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; __Pyx_INCREF(((PyObject *)__pyx_v_offer)); __Pyx_GIVEREF(((PyObject *)__pyx_v_offer)); PyTuple_SET_ITEM(__pyx_t_7, 0+1, ((PyObject *)__pyx_v_offer)); - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 811, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 812, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } @@ -11740,7 +12004,7 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - /* "trade.pyx":810 + /* "trade.pyx":811 * if self.trade_logging == 2: * self._log_receive_accept_group(offer) * elif self.trade_logging == 1: # <<<<<<<<<<<<<< @@ -11750,7 +12014,7 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py } __pyx_L8:; - /* "trade.pyx":806 + /* "trade.pyx":807 * elif typ == '!s': * self._open_offers_sell[msg.good][msg.id] = msg * elif typ == '_p': # <<<<<<<<<<<<<< @@ -11760,24 +12024,24 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py goto __pyx_L7; } - /* "trade.pyx":812 + /* "trade.pyx":813 * elif self.trade_logging == 1: * self._log_receive_accept_agent(offer) * elif typ == '_r': # <<<<<<<<<<<<<< * self._receive_reject(msg) * elif typ == '_g': */ - __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_typ, __pyx_n_s_r, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 812, __pyx_L1_error) + __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_typ, __pyx_n_s_r, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 813, __pyx_L1_error) if (__pyx_t_9) { - /* "trade.pyx":813 + /* "trade.pyx":814 * self._log_receive_accept_agent(offer) * elif typ == '_r': * self._receive_reject(msg) # <<<<<<<<<<<<<< * elif typ == '_g': - * self._haves[msg[0]] += msg[1] + * self._inventory.haves[msg[0]] += msg[1] */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_receive_reject); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 813, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_receive_reject); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 814, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { @@ -11790,13 +12054,13 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py } } if (!__pyx_t_7) { - __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_msg); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 813, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_msg); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 814, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_msg}; - __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 813, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 814, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_5); } else @@ -11804,19 +12068,19 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_msg}; - __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 813, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 814, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 813, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 814, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = NULL; __Pyx_INCREF(__pyx_v_msg); __Pyx_GIVEREF(__pyx_v_msg); PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_msg); - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 813, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 814, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } @@ -11824,7 +12088,7 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - /* "trade.pyx":812 + /* "trade.pyx":813 * elif self.trade_logging == 1: * self._log_receive_accept_agent(offer) * elif typ == '_r': # <<<<<<<<<<<<<< @@ -11834,78 +12098,81 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py goto __pyx_L7; } - /* "trade.pyx":814 + /* "trade.pyx":815 * elif typ == '_r': * self._receive_reject(msg) * elif typ == '_g': # <<<<<<<<<<<<<< - * self._haves[msg[0]] += msg[1] + * self._inventory.haves[msg[0]] += msg[1] * elif typ == '_q': */ - __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_typ, __pyx_n_s_g, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 814, __pyx_L1_error) + __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_typ, __pyx_n_s_g, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 815, __pyx_L1_error) if (__pyx_t_9) { - /* "trade.pyx":815 + /* "trade.pyx":816 * self._receive_reject(msg) * elif typ == '_g': - * self._haves[msg[0]] += msg[1] # <<<<<<<<<<<<<< + * self._inventory.haves[msg[0]] += msg[1] # <<<<<<<<<<<<<< * elif typ == '_q': * self._quotes[msg.id] = msg */ - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 815, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 816, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_msg, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 815, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_haves); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 816, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyObject_GetItem(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 815, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_msg, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 816, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyObject_GetItem(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 816, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_msg, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 815, __pyx_L1_error) + __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_msg, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 816, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_10 = PyNumber_InPlaceAdd(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 815, __pyx_L1_error) + __pyx_t_10 = PyNumber_InPlaceAdd(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 816, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_t_4, __pyx_t_10) < 0)) __PYX_ERR(0, 815, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_4, __pyx_t_5, __pyx_t_10) < 0)) __PYX_ERR(0, 816, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "trade.pyx":814 + /* "trade.pyx":815 * elif typ == '_r': * self._receive_reject(msg) * elif typ == '_g': # <<<<<<<<<<<<<< - * self._haves[msg[0]] += msg[1] + * self._inventory.haves[msg[0]] += msg[1] * elif typ == '_q': */ goto __pyx_L7; } - /* "trade.pyx":816 + /* "trade.pyx":817 * elif typ == '_g': - * self._haves[msg[0]] += msg[1] + * self._inventory.haves[msg[0]] += msg[1] * elif typ == '_q': # <<<<<<<<<<<<<< * self._quotes[msg.id] = msg * elif typ == '!o': */ - __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_typ, __pyx_n_s_q, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 816, __pyx_L1_error) + __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_typ, __pyx_n_s_q, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 817, __pyx_L1_error) if (__pyx_t_9) { - /* "trade.pyx":817 - * self._haves[msg[0]] += msg[1] + /* "trade.pyx":818 + * self._inventory.haves[msg[0]] += msg[1] * elif typ == '_q': * self._quotes[msg.id] = msg # <<<<<<<<<<<<<< * elif typ == '!o': * self._contract_offers[msg.good].append(msg) */ - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_quotes); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 817, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 817, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_quotes); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 818, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_t_4, __pyx_v_msg) < 0)) __PYX_ERR(0, 817, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 818, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + if (unlikely(PyObject_SetItem(__pyx_t_4, __pyx_t_5, __pyx_v_msg) < 0)) __PYX_ERR(0, 818, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - /* "trade.pyx":816 + /* "trade.pyx":817 * elif typ == '_g': - * self._haves[msg[0]] += msg[1] + * self._inventory.haves[msg[0]] += msg[1] * elif typ == '_q': # <<<<<<<<<<<<<< * self._quotes[msg.id] = msg * elif typ == '!o': @@ -11913,35 +12180,35 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py goto __pyx_L7; } - /* "trade.pyx":818 + /* "trade.pyx":819 * elif typ == '_q': * self._quotes[msg.id] = msg * elif typ == '!o': # <<<<<<<<<<<<<< * self._contract_offers[msg.good].append(msg) * elif typ == '_ac': */ - __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_typ, __pyx_kp_s_o, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 818, __pyx_L1_error) + __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_typ, __pyx_kp_s_o, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 819, __pyx_L1_error) if (__pyx_t_9) { - /* "trade.pyx":819 + /* "trade.pyx":820 * self._quotes[msg.id] = msg * elif typ == '!o': * self._contract_offers[msg.good].append(msg) # <<<<<<<<<<<<<< * elif typ == '_ac': * contract = self._contract_offers_made[msg.id] */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contract_offers); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 819, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_good); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 819, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contract_offers); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 820, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_10 = PyObject_GetItem(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 819, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_good); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 820, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_10 = PyObject_GetItem(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 820, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_11 = __Pyx_PyObject_Append(__pyx_t_10, __pyx_v_msg); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 819, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_11 = __Pyx_PyObject_Append(__pyx_t_10, __pyx_v_msg); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 820, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - /* "trade.pyx":818 + /* "trade.pyx":819 * elif typ == '_q': * self._quotes[msg.id] = msg * elif typ == '!o': # <<<<<<<<<<<<<< @@ -11951,90 +12218,90 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py goto __pyx_L7; } - /* "trade.pyx":820 + /* "trade.pyx":821 * elif typ == '!o': * self._contract_offers[msg.good].append(msg) * elif typ == '_ac': # <<<<<<<<<<<<<< * contract = self._contract_offers_made[msg.id] * if contract.pay_group == self.group and contract.pay_id == self.id: */ - __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_typ, __pyx_n_s_ac, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 820, __pyx_L1_error) + __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_typ, __pyx_n_s_ac, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 821, __pyx_L1_error) if (__pyx_t_9) { - /* "trade.pyx":821 + /* "trade.pyx":822 * self._contract_offers[msg.good].append(msg) * elif typ == '_ac': * contract = self._contract_offers_made[msg.id] # <<<<<<<<<<<<<< * if contract.pay_group == self.group and contract.pay_id == self.id: * self._contracts_pay[contract.good][contract.id] = contract */ - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contract_offers_made); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 821, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contract_offers_made); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 822, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 821, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyObject_GetItem(__pyx_t_10, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 821, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 822, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyObject_GetItem(__pyx_t_10, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 822, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_XDECREF_SET(__pyx_v_contract, __pyx_t_4); - __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF_SET(__pyx_v_contract, __pyx_t_5); + __pyx_t_5 = 0; - /* "trade.pyx":822 + /* "trade.pyx":823 * elif typ == '_ac': * contract = self._contract_offers_made[msg.id] * if contract.pay_group == self.group and contract.pay_id == self.id: # <<<<<<<<<<<<<< * self._contracts_pay[contract.good][contract.id] = contract * else: */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_contract, __pyx_n_s_pay_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 822, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_group); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 822, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_contract, __pyx_n_s_pay_group); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 823, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_10 = PyObject_RichCompare(__pyx_t_4, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 822, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 823, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_10 = PyObject_RichCompare(__pyx_t_5, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 823, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 822, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 823, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (__pyx_t_12) { } else { __pyx_t_9 = __pyx_t_12; goto __pyx_L10_bool_binop_done; } - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_contract, __pyx_n_s_pay_id); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 822, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_contract, __pyx_n_s_pay_id); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 823, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 822, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_10, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 822, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 823, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyObject_RichCompare(__pyx_t_10, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 823, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 822, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 823, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_9 = __pyx_t_12; __pyx_L10_bool_binop_done:; if (__pyx_t_9) { - /* "trade.pyx":823 + /* "trade.pyx":824 * contract = self._contract_offers_made[msg.id] * if contract.pay_group == self.group and contract.pay_id == self.id: * self._contracts_pay[contract.good][contract.id] = contract # <<<<<<<<<<<<<< * else: * self._contracts_deliver[contract.good][contract.id] = contract */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contracts_pay); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 823, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_contract, __pyx_n_s_good); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 823, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contracts_pay); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 824, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_10 = PyObject_GetItem(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 823, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_contract, __pyx_n_s_good); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 824, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_10 = PyObject_GetItem(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 824, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_contract, __pyx_n_s_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 823, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - if (unlikely(PyObject_SetItem(__pyx_t_10, __pyx_t_5, __pyx_v_contract) < 0)) __PYX_ERR(0, 823, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_contract, __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 824, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + if (unlikely(PyObject_SetItem(__pyx_t_10, __pyx_t_4, __pyx_v_contract) < 0)) __PYX_ERR(0, 824, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "trade.pyx":822 + /* "trade.pyx":823 * elif typ == '_ac': * contract = self._contract_offers_made[msg.id] * if contract.pay_group == self.group and contract.pay_id == self.id: # <<<<<<<<<<<<<< @@ -12044,7 +12311,7 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py goto __pyx_L9; } - /* "trade.pyx":825 + /* "trade.pyx":826 * self._contracts_pay[contract.good][contract.id] = contract * else: * self._contracts_deliver[contract.good][contract.id] = contract # <<<<<<<<<<<<<< @@ -12052,23 +12319,23 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py * if msg.pay_group == self.group and msg.pay_id == self.id: */ /*else*/ { - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contracts_deliver); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 825, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_contract, __pyx_n_s_good); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 825, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_4 = PyObject_GetItem(__pyx_t_5, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 825, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contracts_deliver); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 826, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_contract, __pyx_n_s_id); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 825, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_contract, __pyx_n_s_good); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 826, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - if (unlikely(PyObject_SetItem(__pyx_t_4, __pyx_t_10, __pyx_v_contract) < 0)) __PYX_ERR(0, 825, __pyx_L1_error) + __pyx_t_5 = PyObject_GetItem(__pyx_t_4, __pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 826, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_contract, __pyx_n_s_id); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 826, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_t_10, __pyx_v_contract) < 0)) __PYX_ERR(0, 826, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_L9:; - /* "trade.pyx":820 + /* "trade.pyx":821 * elif typ == '!o': * self._contract_offers[msg.good].append(msg) * elif typ == '_ac': # <<<<<<<<<<<<<< @@ -12078,232 +12345,232 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py goto __pyx_L7; } - /* "trade.pyx":826 + /* "trade.pyx":827 * else: * self._contracts_deliver[contract.good][contract.id] = contract * elif typ == '_dp': # <<<<<<<<<<<<<< * if msg.pay_group == self.group and msg.pay_id == self.id: - * self._haves[msg.good] += msg.quantity + * self._inventory[msg.good] += msg.quantity */ - __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_typ, __pyx_n_s_dp, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 826, __pyx_L1_error) + __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_typ, __pyx_n_s_dp, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 827, __pyx_L1_error) if (__pyx_t_9) { - /* "trade.pyx":827 + /* "trade.pyx":828 * self._contracts_deliver[contract.good][contract.id] = contract * elif typ == '_dp': * if msg.pay_group == self.group and msg.pay_id == self.id: # <<<<<<<<<<<<<< - * self._haves[msg.good] += msg.quantity + * self._inventory[msg.good] += msg.quantity * self._contracts_pay[msg.good][msg.id].delivered.append(self.round) */ - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_pay_group); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 827, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_pay_group); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 828, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 827, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyObject_RichCompare(__pyx_t_10, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 827, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_group); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 828, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = PyObject_RichCompare(__pyx_t_10, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 828, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 827, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 828, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_12) { } else { __pyx_t_9 = __pyx_t_12; goto __pyx_L13_bool_binop_done; } - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_pay_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 827, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 827, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_pay_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 828, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_10 = PyObject_RichCompare(__pyx_t_5, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 827, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 828, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_10 = PyObject_RichCompare(__pyx_t_4, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 828, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 827, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 828, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_9 = __pyx_t_12; __pyx_L13_bool_binop_done:; if (__pyx_t_9) { - /* "trade.pyx":828 + /* "trade.pyx":829 * elif typ == '_dp': * if msg.pay_group == self.group and msg.pay_id == self.id: - * self._haves[msg.good] += msg.quantity # <<<<<<<<<<<<<< + * self._inventory[msg.good] += msg.quantity # <<<<<<<<<<<<<< * self._contracts_pay[msg.good][msg.id].delivered.append(self.round) * else: */ - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 828, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 829, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_good); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 828, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyObject_GetItem(__pyx_t_10, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 828, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_good); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 829, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_quantity); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 828, __pyx_L1_error) + __pyx_t_4 = PyObject_GetItem(__pyx_t_10, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 829, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_quantity); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 829, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 828, __pyx_L1_error) + __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 829, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_10, __pyx_t_4, __pyx_t_6) < 0)) __PYX_ERR(0, 828, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_10, __pyx_t_5, __pyx_t_6) < 0)) __PYX_ERR(0, 829, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - /* "trade.pyx":829 + /* "trade.pyx":830 * if msg.pay_group == self.group and msg.pay_id == self.id: - * self._haves[msg.good] += msg.quantity + * self._inventory[msg.good] += msg.quantity * self._contracts_pay[msg.good][msg.id].delivered.append(self.round) # <<<<<<<<<<<<<< * else: - * self._haves['money'] += msg.quantity * msg.price + * self._inventory['money'] += msg.quantity * msg.price */ - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contracts_pay); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 829, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contracts_pay); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 830, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_good); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 829, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyObject_GetItem(__pyx_t_10, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 829, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_good); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 830, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyObject_GetItem(__pyx_t_10, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 830, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 829, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_10 = PyObject_GetItem(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 829, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 830, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_10 = PyObject_GetItem(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 830, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_delivered); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 829, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_delivered); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 830, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_round); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 829, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_round); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 830, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __pyx_t_11 = __Pyx_PyObject_Append(__pyx_t_4, __pyx_t_10); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 829, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_11 = __Pyx_PyObject_Append(__pyx_t_5, __pyx_t_10); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 830, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - /* "trade.pyx":827 + /* "trade.pyx":828 * self._contracts_deliver[contract.good][contract.id] = contract * elif typ == '_dp': * if msg.pay_group == self.group and msg.pay_id == self.id: # <<<<<<<<<<<<<< - * self._haves[msg.good] += msg.quantity + * self._inventory[msg.good] += msg.quantity * self._contracts_pay[msg.good][msg.id].delivered.append(self.round) */ goto __pyx_L12; } - /* "trade.pyx":831 + /* "trade.pyx":832 * self._contracts_pay[msg.good][msg.id].delivered.append(self.round) * else: - * self._haves['money'] += msg.quantity * msg.price # <<<<<<<<<<<<<< + * self._inventory['money'] += msg.quantity * msg.price # <<<<<<<<<<<<<< * self._contracts_deliver[msg.good][msg.id].paid.append(self.round) * */ /*else*/ { - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_haves); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 831, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_inventory); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 832, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_INCREF(__pyx_n_s_money); __pyx_t_13 = __pyx_n_s_money; - __pyx_t_4 = PyObject_GetItem(__pyx_t_10, __pyx_t_13); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 831, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_quantity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 831, __pyx_L1_error) + __pyx_t_5 = PyObject_GetItem(__pyx_t_10, __pyx_t_13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 832, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_quantity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 832, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_price); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 831, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_price); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 832, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_5 = PyNumber_Multiply(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 831, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = PyNumber_Multiply(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 832, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 831, __pyx_L1_error) + __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 832, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_10, __pyx_t_13, __pyx_t_7) < 0)) __PYX_ERR(0, 831, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(PyObject_SetItem(__pyx_t_10, __pyx_t_13, __pyx_t_7) < 0)) __PYX_ERR(0, 832, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - /* "trade.pyx":832 + /* "trade.pyx":833 * else: - * self._haves['money'] += msg.quantity * msg.price + * self._inventory['money'] += msg.quantity * msg.price * self._contracts_deliver[msg.good][msg.id].paid.append(self.round) # <<<<<<<<<<<<<< * * elif typ == '!d': */ - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contracts_deliver); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 832, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contracts_deliver); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 833, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_good); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 832, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_good); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 833, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_5 = PyObject_GetItem(__pyx_t_10, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 832, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = PyObject_GetItem(__pyx_t_10, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 833, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_id); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 832, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_msg, __pyx_n_s_id); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 833, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_10 = PyObject_GetItem(__pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 832, __pyx_L1_error) + __pyx_t_10 = PyObject_GetItem(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 833, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_paid); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 832, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_paid); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 833, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_round); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 832, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_round); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 833, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __pyx_t_11 = __Pyx_PyObject_Append(__pyx_t_7, __pyx_t_10); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 832, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_Append(__pyx_t_7, __pyx_t_10); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 833, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_L12:; - /* "trade.pyx":826 + /* "trade.pyx":827 * else: * self._contracts_deliver[contract.good][contract.id] = contract * elif typ == '_dp': # <<<<<<<<<<<<<< * if msg.pay_group == self.group and msg.pay_id == self.id: - * self._haves[msg.good] += msg.quantity + * self._inventory[msg.good] += msg.quantity */ goto __pyx_L7; } - /* "trade.pyx":834 + /* "trade.pyx":835 * self._contracts_deliver[msg.good][msg.id].paid.append(self.round) * * elif typ == '!d': # <<<<<<<<<<<<<< * if msg[0] == 'r': * del self._contracts_pay[msg[1]][msg[2]] */ - __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_typ, __pyx_kp_s_d, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 834, __pyx_L1_error) + __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_typ, __pyx_kp_s_d, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 835, __pyx_L1_error) if (__pyx_t_9) { - /* "trade.pyx":835 + /* "trade.pyx":836 * * elif typ == '!d': * if msg[0] == 'r': # <<<<<<<<<<<<<< * del self._contracts_pay[msg[1]][msg[2]] * if msg[0] == 'd': */ - __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_msg, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 835, __pyx_L1_error) + __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_msg, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 836, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_t_10, __pyx_n_s_r_2, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 835, __pyx_L1_error) + __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_t_10, __pyx_n_s_r_2, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 836, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (__pyx_t_9) { - /* "trade.pyx":836 + /* "trade.pyx":837 * elif typ == '!d': * if msg[0] == 'r': * del self._contracts_pay[msg[1]][msg[2]] # <<<<<<<<<<<<<< * if msg[0] == 'd': * del self._contracts_deliver[msg[1]][msg[2]] */ - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contracts_pay); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 836, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contracts_pay); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 837, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_msg, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 836, __pyx_L1_error) + __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_msg, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 837, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_5 = PyObject_GetItem(__pyx_t_10, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 836, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = PyObject_GetItem(__pyx_t_10, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 837, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_msg, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 836, __pyx_L1_error) + __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_msg, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 837, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - if (unlikely(PyObject_DelItem(__pyx_t_5, __pyx_t_7) < 0)) __PYX_ERR(0, 836, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (unlikely(PyObject_DelItem(__pyx_t_4, __pyx_t_7) < 0)) __PYX_ERR(0, 837, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - /* "trade.pyx":835 + /* "trade.pyx":836 * * elif typ == '!d': * if msg[0] == 'r': # <<<<<<<<<<<<<< @@ -12312,41 +12579,41 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py */ } - /* "trade.pyx":837 + /* "trade.pyx":838 * if msg[0] == 'r': * del self._contracts_pay[msg[1]][msg[2]] * if msg[0] == 'd': # <<<<<<<<<<<<<< * del self._contracts_deliver[msg[1]][msg[2]] * else: */ - __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_msg, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 837, __pyx_L1_error) + __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_msg, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 838, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_t_7, __pyx_n_s_d_2, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 837, __pyx_L1_error) + __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_t_7, __pyx_n_s_d_2, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 838, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_9) { - /* "trade.pyx":838 + /* "trade.pyx":839 * del self._contracts_pay[msg[1]][msg[2]] * if msg[0] == 'd': * del self._contracts_deliver[msg[1]][msg[2]] # <<<<<<<<<<<<<< * else: * self._msgs.setdefault(typ, []).append(msg) */ - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contracts_deliver); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 838, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contracts_deliver); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 839, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_msg, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 838, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_10 = PyObject_GetItem(__pyx_t_7, __pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 838, __pyx_L1_error) + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_msg, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 839, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_10 = PyObject_GetItem(__pyx_t_7, __pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 839, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_msg, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 838, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - if (unlikely(PyObject_DelItem(__pyx_t_10, __pyx_t_5) < 0)) __PYX_ERR(0, 838, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_msg, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 839, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + if (unlikely(PyObject_DelItem(__pyx_t_10, __pyx_t_4) < 0)) __PYX_ERR(0, 839, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "trade.pyx":837 + /* "trade.pyx":838 * if msg[0] == 'r': * del self._contracts_pay[msg[1]][msg[2]] * if msg[0] == 'd': # <<<<<<<<<<<<<< @@ -12355,7 +12622,7 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py */ } - /* "trade.pyx":834 + /* "trade.pyx":835 * self._contracts_deliver[msg.good][msg.id].paid.append(self.round) * * elif typ == '!d': # <<<<<<<<<<<<<< @@ -12365,7 +12632,7 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py goto __pyx_L7; } - /* "trade.pyx":840 + /* "trade.pyx":841 * del self._contracts_deliver[msg[1]][msg[2]] * else: * self._msgs.setdefault(typ, []).append(msg) # <<<<<<<<<<<<<< @@ -12373,20 +12640,20 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py * # TODO when cython supports function overloading overload this function with compare_with_ties(int x, int y) */ /*else*/ { - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_msgs); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 840, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_msgs); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 841, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_setdefault); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 840, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_setdefault); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 841, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 840, __pyx_L1_error) + __pyx_t_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 841, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __pyx_t_4 = NULL; + __pyx_t_5 = NULL; __pyx_t_14 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7); - if (likely(__pyx_t_4)) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); - __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_14 = 1; @@ -12394,27 +12661,27 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_typ, __pyx_t_10}; - __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 840, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_5); + PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_typ, __pyx_t_10}; + __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 841, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_typ, __pyx_t_10}; - __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 840, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_5); + PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_typ, __pyx_t_10}; + __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 841, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif { - __pyx_t_6 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 840, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 841, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - if (__pyx_t_4) { - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; + if (__pyx_t_5) { + __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_v_typ); __Pyx_GIVEREF(__pyx_v_typ); @@ -12422,17 +12689,17 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_14, __pyx_t_10); __pyx_t_10 = 0; - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 840, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 841, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_11 = __Pyx_PyObject_Append(__pyx_t_5, __pyx_v_msg); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 840, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_11 = __Pyx_PyObject_Append(__pyx_t_4, __pyx_v_msg); if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 841, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_L7:; - /* "trade.pyx":801 + /* "trade.pyx":802 * """ * cdef Offer offer * for typ, msg in incomming_messages: # <<<<<<<<<<<<<< @@ -12442,7 +12709,7 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":790 + /* "trade.pyx":791 * * * def _clearing__end_of_subround(self, incomming_messages): # <<<<<<<<<<<<<< @@ -12473,7 +12740,7 @@ static PyObject *__pyx_pf_5trade_5Trade_46_clearing__end_of_subround(struct __py return __pyx_r; } -/* "trade.pyx":843 +/* "trade.pyx":844 * * # TODO when cython supports function overloading overload this function with compare_with_ties(int x, int y) * cdef int compare_with_ties(double x, double y): # <<<<<<<<<<<<<< @@ -12490,7 +12757,7 @@ static int __pyx_f_5trade_compare_with_ties(double __pyx_v_x, double __pyx_v_y) int __pyx_t_4; __Pyx_RefNannySetupContext("compare_with_ties", 0); - /* "trade.pyx":844 + /* "trade.pyx":845 * # TODO when cython supports function overloading overload this function with compare_with_ties(int x, int y) * cdef int compare_with_ties(double x, double y): * if x < y: # <<<<<<<<<<<<<< @@ -12500,7 +12767,7 @@ static int __pyx_f_5trade_compare_with_ties(double __pyx_v_x, double __pyx_v_y) __pyx_t_1 = ((__pyx_v_x < __pyx_v_y) != 0); if (__pyx_t_1) { - /* "trade.pyx":845 + /* "trade.pyx":846 * cdef int compare_with_ties(double x, double y): * if x < y: * return -1 # <<<<<<<<<<<<<< @@ -12510,7 +12777,7 @@ static int __pyx_f_5trade_compare_with_ties(double __pyx_v_x, double __pyx_v_y) __pyx_r = -1; goto __pyx_L0; - /* "trade.pyx":844 + /* "trade.pyx":845 * # TODO when cython supports function overloading overload this function with compare_with_ties(int x, int y) * cdef int compare_with_ties(double x, double y): * if x < y: # <<<<<<<<<<<<<< @@ -12519,7 +12786,7 @@ static int __pyx_f_5trade_compare_with_ties(double __pyx_v_x, double __pyx_v_y) */ } - /* "trade.pyx":846 + /* "trade.pyx":847 * if x < y: * return -1 * elif x > y: # <<<<<<<<<<<<<< @@ -12529,7 +12796,7 @@ static int __pyx_f_5trade_compare_with_ties(double __pyx_v_x, double __pyx_v_y) __pyx_t_1 = ((__pyx_v_x > __pyx_v_y) != 0); if (__pyx_t_1) { - /* "trade.pyx":847 + /* "trade.pyx":848 * return -1 * elif x > y: * return 1 # <<<<<<<<<<<<<< @@ -12539,7 +12806,7 @@ static int __pyx_f_5trade_compare_with_ties(double __pyx_v_x, double __pyx_v_y) __pyx_r = 1; goto __pyx_L0; - /* "trade.pyx":846 + /* "trade.pyx":847 * if x < y: * return -1 * elif x > y: # <<<<<<<<<<<<<< @@ -12548,34 +12815,34 @@ static int __pyx_f_5trade_compare_with_ties(double __pyx_v_x, double __pyx_v_y) */ } - /* "trade.pyx":849 + /* "trade.pyx":850 * return 1 * else: * return random.randint(0, 1) * 2 - 1 # <<<<<<<<<<<<<< * */ /*else*/ { - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 849, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 850, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_randint); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 849, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_randint); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 850, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 849, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 850, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_int_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 849, __pyx_L1_error) + __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_int_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 850, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyInt_SubtractObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 849, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyInt_SubtractObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 850, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 849, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 850, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_4; goto __pyx_L0; } - /* "trade.pyx":843 + /* "trade.pyx":844 * * # TODO when cython supports function overloading overload this function with compare_with_ties(int x, int y) * cdef int compare_with_ties(double x, double y): # <<<<<<<<<<<<<< @@ -12805,7 +13072,7 @@ static PyTypeObject __pyx_type_5trade_Offer = { 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - " This is an offer container that is send to the other agent. You can\n access the offer container both at the receiver as well as at the sender,\n if you have saved the offer. (e.G. self.offer = self.sell(...))\n\n it has the following properties:\n sender_group:\n this is the group name of the sender\n\n sender_id:\n this is the ID of the sender\n\n receiver_group:\n This is the group name of the receiver\n\n receiver_id:\n this is the ID of the sender\n\n good:\n the good offered or demanded\n\n quantity:\n the quantity offered or demanded\n\n price:\n the suggested tansaction price\n\n sell:\n this can have the values False for buy; True for sell\n\n status:\n 'new':\n has been created, but not answered\n\n 'accepted':\n trade fully accepted\n\n 'rejected':\n trade rejected\n\n 'pending':\n offer has not yet answered, and is not older than one round.\n\n 'perished':\n the **perishable** good was not accepted by the end of the round\n and therefore perished.\n\n final_quantity:\n If the offer has been answerd this returns the actual quantity\n bought or sold. (Equal to quantity if the offer was accepted fully)\n id:\n a unique identifier\n ", /*tp_doc*/ + " This is an offer container that is send to the other agent. You can\n access the offer container both at the receiver as well as at the sender,\n if you have saved the offer. (e.G. self.offer = self.sell(...))\n\n it has the following properties:\n sender_group:\n this is the group name of the sender\n\n sender_id:\n this is the ID of the sender\n\n receiver_group:\n This is the group name of the receiver\n\n receiver_id:\n this is the ID of the sender\n\n currency:\n The other good against which the good is traded.\n\n good:\n the good offered or demanded\n\n quantity:\n the quantity offered or demanded\n\n price:\n the suggested transaction price\n\n sell:\n this can have the values False for buy; True for sell\n\n status:\n 'new':\n has been created, but not answered\n\n 'accepted':\n trade fully accepted\n\n 'rejected':\n trade rejected\n\n 'pending':\n offer has not yet answered, and is not older than one round.\n\n 'perished':\n the **perishable** good was not accepted by the end of the round\n and therefore perished.\n\n final_quantity:\n If the offer has been answerd this returns the actual quantity\n bought or sold. (Equal to quantity if the offer was accepted fully)\n id:\n a unique identifier\n ", /*tp_doc*/ __pyx_tp_traverse_5trade_Offer, /*tp_traverse*/ __pyx_tp_clear_5trade_Offer, /*tp_clear*/ 0, /*tp_richcompare*/ @@ -12915,7 +13182,7 @@ static PyTypeObject __pyx_type_5trade_Trade = { 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ - " Agents can trade with each other. The clearing of the trade is taken care\n of fully by ABCE.\n Selling a good works in the following way:\n\n 1. An agent sends an offer. :meth:`~.sell`\n\n *The good offered is blocked and self.possession(...) does shows the decreased amount.*\n\n 2. **Next subround:** An agent receives the offer :meth:`~.get_offers`, and can\n :meth:`~.accept`, :meth:`~.reject` or partially accept it. :meth:`~.accept`\n\n *The good is credited and the price is deducted from the agent's possessions.*\n\n 3. **Next subround:**\n\n - in case of acceptance *the money is automatically credited.*\n - in case of partial acceptance *the money is credited and part of the blocked good is unblocked.*\n - in case of rejection *the good is unblocked.*\n\n Analogously for buying: :meth:`~.buy`\n\n Example::\n\n # Agent 1\n def sales(self):\n self.remember_trade = self.sell('Household', 0, 'cookies', quantity=5, price=self.price)\n\n # Agent 2\n def receive_sale(self):\n oo = self.get_offers('cookies')\n for offer in oo:\n if offer.price < 0.3:\n try:\n self.accept(offer)\n except NotEnoughGoods:\n self.accept(offer, self.possession('money') / offer.price)\n else:\n self.reject(offer)\n\n # Agent 1, subround 3\n def learning(self):\n offer = self.info(self.remember_trade)\n if offer.status == 'reject':\n self.price *= .9\n elif offer.status = 'accepted':\n self.price *= offer.final_quantity / offer.quantity\n Example::\n\n # Agent 1\n def sales(self):\n self.remember_trade = self.sell('Household', 0, 'cookies', quantity=5, price=self.price, currency='dollars')\n\n # Agent 2\n def receive_sale(self):""\n oo = self.get_offers('cookies')\n for offer in oo:\n if ((offer.currency == 'dollars' and offer.price < 0.3 * exchange_rate)\n or (offer.currency == 'euros' and dollars'offer.price < 0.3)):\n\n try:\n self.accept(offer)\n except NotEnoughGoods:\n self.accept(offer, self.possession('money') / offer.price)\n else:\n self.reject(offer)\n\n If we did not implement a barter class, but one can use this class as a barter class,\n ", /*tp_doc*/ + " Agents can trade with each other. The clearing of the trade is taken care\n of fully by ABCE.\n Selling a good works in the following way:\n\n 1. An agent sends an offer. :meth:`~.sell`\n\n *The good offered is blocked and self.possession(...) does shows the decreased amount.*\n\n 2. **Next subround:** An agent receives the offer :meth:`~.get_offers`, and can\n :meth:`~.accept`, :meth:`~.reject` or partially accept it. :meth:`~.accept`\n\n *The good is credited and the price is deducted from the agent's possessions.*\n\n 3. **Next subround:**\n\n - in case of acceptance *the money is automatically credited.*\n - in case of partial acceptance *the money is credited and part of the blocked good is unblocked.*\n - in case of rejection *the good is unblocked.*\n\n Analogously for buying: :meth:`~.buy`\n\n Example::\n\n # Agent 1\n def sales(self):\n self.remember_trade = self.sell('Household', 0, 'cookies', quantity=5, price=self.price)\n\n # Agent 2\n def receive_sale(self):\n oo = self.get_offers('cookies')\n for offer in oo:\n if offer.price < 0.3:\n try:\n self.accept(offer)\n except NotEnoughGoods:\n self.accept(offer, self['money'] / offer.price)\n else:\n self.reject(offer)\n\n # Agent 1, subround 3\n def learning(self):\n offer = self.info(self.remember_trade)\n if offer.status == 'reject':\n self.price *= .9\n elif offer.status = 'accepted':\n self.price *= offer.final_quantity / offer.quantity\n Example::\n\n # Agent 1\n def sales(self):\n self.remember_trade = self.sell('Household', 0, 'cookies', quantity=5, price=self.price, currency='dollars')\n\n # Agent 2\n def receive_sale(self):\n "" oo = self.get_offers('cookies')\n for offer in oo:\n if ((offer.currency == 'dollars' and offer.price < 0.3 * exchange_rate)\n or (offer.currency == 'euros' and dollars'offer.price < 0.3)):\n\n try:\n self.accept(offer)\n except NotEnoughGoods:\n self.accept(offer, self['money'] / offer.price)\n else:\n self.reject(offer)\n\n If we did not implement a barter class, but one can use this class as a barter class,\n ", /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ @@ -12980,6 +13247,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1}, {&__pyx_kp_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 0}, {&__pyx_n_s_buy, __pyx_k_buy, sizeof(__pyx_k_buy), 0, 0, 1, 1}, + {&__pyx_n_s_commit, __pyx_k_commit, sizeof(__pyx_k_commit), 0, 0, 1, 1}, {&__pyx_n_s_contract_offers, __pyx_k_contract_offers, sizeof(__pyx_k_contract_offers), 0, 0, 1, 1}, {&__pyx_n_s_contract_offers_made, __pyx_k_contract_offers_made, sizeof(__pyx_k_contract_offers_made), 0, 0, 1, 1}, {&__pyx_n_s_contracts_deliver, __pyx_k_contracts_deliver, sizeof(__pyx_k_contracts_deliver), 0, 0, 1, 1}, @@ -13006,6 +13274,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_haves, __pyx_k_haves, sizeof(__pyx_k_haves), 0, 0, 1, 1}, {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, + {&__pyx_n_s_inventory, __pyx_k_inventory, sizeof(__pyx_k_inventory), 0, 0, 1, 1}, {&__pyx_n_s_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 0, 1, 1}, {&__pyx_n_s_keys, __pyx_k_keys, sizeof(__pyx_k_keys), 0, 0, 1, 1}, {&__pyx_n_s_log_receive_accept_agent, __pyx_k_log_receive_accept_agent, sizeof(__pyx_k_log_receive_accept_agent), 0, 0, 1, 1}, @@ -13053,7 +13322,9 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_receiver_id, __pyx_k_receiver_id, sizeof(__pyx_k_receiver_id), 0, 0, 1, 1}, {&__pyx_n_s_reject, __pyx_k_reject, sizeof(__pyx_k_reject), 0, 0, 1, 1}, {&__pyx_n_s_rejected, __pyx_k_rejected, sizeof(__pyx_k_rejected), 0, 0, 1, 1}, + {&__pyx_n_s_reserve, __pyx_k_reserve, sizeof(__pyx_k_reserve), 0, 0, 1, 1}, {&__pyx_n_s_reverse, __pyx_k_reverse, sizeof(__pyx_k_reverse), 0, 0, 1, 1}, + {&__pyx_n_s_rewind, __pyx_k_rewind, sizeof(__pyx_k_rewind), 0, 0, 1, 1}, {&__pyx_n_s_round, __pyx_k_round, sizeof(__pyx_k_round), 0, 0, 1, 1}, {&__pyx_kp_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 0}, {&__pyx_kp_s_s__i, __pyx_k_s__i, sizeof(__pyx_k_s__i), 0, 0, 1, 0}, @@ -13079,7 +13350,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_AssertionError = __Pyx_GetBuiltinName(__pyx_n_s_AssertionError); if (!__pyx_builtin_AssertionError) __PYX_ERR(0, 586, __pyx_L1_error) + __pyx_builtin_AssertionError = __Pyx_GetBuiltinName(__pyx_n_s_AssertionError); if (!__pyx_builtin_AssertionError) __PYX_ERR(0, 587, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; @@ -13089,13 +13360,13 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "trade.pyx":849 + /* "trade.pyx":850 * return 1 * else: * return random.randint(0, 1) * 2 - 1 # <<<<<<<<<<<<<< * */ - __pyx_tuple__6 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_1); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 849, __pyx_L1_error) + __pyx_tuple__6 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_1); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 850, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); @@ -13108,17 +13379,17 @@ static int __Pyx_InitCachedConstants(void) { */ __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_taghawi_Dropbox_workspace, __pyx_n_s_get_epsilon, 45, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 45, __pyx_L1_error) - /* "trade.pyx":161 + /* "trade.pyx":164 * self.made, self.status_round) * * def rebuild_offer(str sender_group, int sender_id, str receiver_group, # <<<<<<<<<<<<<< * int receiver_id, object good, double quantity, double price, * str currency, bint sell, str status, double final_quantity, */ - __pyx_tuple__8 = PyTuple_Pack(14, __pyx_n_s_sender_group, __pyx_n_s_sender_id, __pyx_n_s_receiver_group, __pyx_n_s_receiver_id, __pyx_n_s_good, __pyx_n_s_quantity, __pyx_n_s_price, __pyx_n_s_currency, __pyx_n_s_sell, __pyx_n_s_status, __pyx_n_s_final_quantity, __pyx_n_s_id, __pyx_n_s_made, __pyx_n_s_status_round); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 161, __pyx_L1_error) + __pyx_tuple__8 = PyTuple_Pack(14, __pyx_n_s_sender_group, __pyx_n_s_sender_id, __pyx_n_s_receiver_group, __pyx_n_s_receiver_id, __pyx_n_s_good, __pyx_n_s_quantity, __pyx_n_s_price, __pyx_n_s_currency, __pyx_n_s_sell, __pyx_n_s_status, __pyx_n_s_final_quantity, __pyx_n_s_id, __pyx_n_s_made, __pyx_n_s_status_round); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 164, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); - __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(14, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_taghawi_Dropbox_workspace, __pyx_n_s_rebuild_offer, 161, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 161, __pyx_L1_error) + __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(14, 0, 14, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_taghawi_Dropbox_workspace, __pyx_n_s_rebuild_offer, 164, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 164, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -13229,10 +13500,10 @@ PyMODINIT_FUNC PyInit_trade(void) __pyx_ptype_5trade_Offer = &__pyx_type_5trade_Offer; __pyx_vtabptr_5trade_Trade = &__pyx_vtable_5trade_Trade; __pyx_vtable_5trade_Trade._reject = (PyObject *(*)(struct __pyx_obj_5trade_Trade *, struct __pyx_obj_5trade_Offer *))__pyx_f_5trade_5Trade__reject; - if (PyType_Ready(&__pyx_type_5trade_Trade) < 0) __PYX_ERR(0, 170, __pyx_L1_error) + if (PyType_Ready(&__pyx_type_5trade_Trade) < 0) __PYX_ERR(0, 173, __pyx_L1_error) __pyx_type_5trade_Trade.tp_print = 0; - if (__Pyx_SetVtable(__pyx_type_5trade_Trade.tp_dict, __pyx_vtabptr_5trade_Trade) < 0) __PYX_ERR(0, 170, __pyx_L1_error) - if (PyObject_SetAttrString(__pyx_m, "Trade", (PyObject *)&__pyx_type_5trade_Trade) < 0) __PYX_ERR(0, 170, __pyx_L1_error) + if (__Pyx_SetVtable(__pyx_type_5trade_Trade.tp_dict, __pyx_vtabptr_5trade_Trade) < 0) __PYX_ERR(0, 173, __pyx_L1_error) + if (PyObject_SetAttrString(__pyx_m, "Trade", (PyObject *)&__pyx_type_5trade_Trade) < 0) __PYX_ERR(0, 173, __pyx_L1_error) __pyx_ptype_5trade_Trade = &__pyx_type_5trade_Trade; /*--- Type import code ---*/ /*--- Variable import code ---*/ @@ -13296,19 +13567,19 @@ PyMODINIT_FUNC PyInit_trade(void) if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_epsilon, __pyx_t_2) < 0) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":161 + /* "trade.pyx":164 * self.made, self.status_round) * * def rebuild_offer(str sender_group, int sender_id, str receiver_group, # <<<<<<<<<<<<<< * int receiver_id, object good, double quantity, double price, * str currency, bint sell, str status, double final_quantity, */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_5trade_3rebuild_offer, NULL, __pyx_n_s_trade); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __pyx_L1_error) + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_5trade_3rebuild_offer, NULL, __pyx_n_s_trade); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 164, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_rebuild_offer, __pyx_t_2) < 0) __PYX_ERR(0, 161, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_rebuild_offer, __pyx_t_2) < 0) __PYX_ERR(0, 164, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":404 + /* "trade.pyx":407 * * def sell(self, receiver, * good, double quantity, double price, str currency='money', double epsilon=epsilon): # <<<<<<<<<<<<<< @@ -13317,7 +13588,7 @@ PyMODINIT_FUNC PyInit_trade(void) */ __pyx_k_ = __pyx_v_5trade_epsilon; - /* "trade.pyx":489 + /* "trade.pyx":492 * * def buy(self, receiver, good, * double quantity, double price, str currency='money', double epsilon=epsilon): # <<<<<<<<<<<<<< @@ -13326,7 +13597,7 @@ PyMODINIT_FUNC PyInit_trade(void) */ __pyx_k__2 = __pyx_v_5trade_epsilon; - /* "trade.pyx":556 + /* "trade.pyx":557 * return offer * * def accept(self, Offer offer, double quantity=-999, double epsilon=epsilon): # <<<<<<<<<<<<<< @@ -13335,8 +13606,8 @@ PyMODINIT_FUNC PyInit_trade(void) */ __pyx_k__3 = __pyx_v_5trade_epsilon; - /* "trade.pyx":721 - * self._haves[offer.currency] += offer.quantity * offer.price + /* "trade.pyx":722 + * self._inventory.rewind(offer.currency, offer.quantity * offer.price) * * def give(self, receiver, good, double quantity, double epsilon=epsilon): # <<<<<<<<<<<<<< * """ gives a good to another agent @@ -13344,7 +13615,7 @@ PyMODINIT_FUNC PyInit_trade(void) */ __pyx_k__4 = __pyx_v_5trade_epsilon; - /* "trade.pyx":763 + /* "trade.pyx":764 * return {good: quantity} * * def take(self, receiver, good, double quantity, double epsilon=epsilon): # <<<<<<<<<<<<<< diff --git a/abce/trade.py b/abce/trade.py index 49697525..d508bb29 100644 --- a/abce/trade.py +++ b/abce/trade.py @@ -33,11 +33,11 @@ .. [1] or :class:`abceagent.FirmMultiTechnologies` for simulations with complex technologies. """ -#******************************************************************************************# -# trade.pyx is written in cython. When you modify trade.pyx you need to compile it with # -# compile.sh and compile.py because the resulting trade.c file is distributed. # -# Don't forget to commit it to git # -#******************************************************************************************# +# ***************************************************************************************** # +# trade.pyx is written in cython. When you modify trade.pyx you need to compile it with # +# compile.sh and compile.py because the resulting trade.c file is distributed. # +# Don't forget to commit it to git # +# ***************************************************************************************** # import random from abce.notenoughgoods import NotEnoughGoods @@ -146,7 +146,7 @@ class Trade: 1. An agent sends an offer. :meth:`~.sell` - *The good offered is blocked and self.possession(...) does shows the decreased amount.* + *ABCE does not allow you to sell the same good twice; self.free(good) shows how much good is not reserved yet* 2. **Next subround:** An agent receives the offer :meth:`~.get_offers`, and can :meth:`~.accept`, :meth:`~.reject` or partially accept it. :meth:`~.accept` @@ -156,7 +156,7 @@ class Trade: 3. **Next subround:** - in case of acceptance *the money is automatically credited.* - - in case of partial acceptance *the money is credited and part of the blocked good is unblocked.* + - in case of partial acceptance *the money is credited and part of the reserved good is unblocked.* - in case of rejection *the good is unblocked.* Analogously for buying: :meth:`~.buy` @@ -175,7 +175,7 @@ def receive_sale(self): try: self.accept(offer) except NotEnoughGoods: - self.accept(offer, self.possession('money') / offer.price) + self.accept(offer, self['money'] / offer.price) else: self.reject(offer) @@ -202,7 +202,7 @@ def receive_sale(self): try: self.accept(offer) except NotEnoughGoods: - self.accept(offer, self.possession('money') / offer.price) + self.accept(offer, self['money'] / offer.price) else: self.reject(offer) @@ -353,7 +353,7 @@ def peak_offers(self, good, sorted=True, descending=False, shuffled=True): Args: good: the good which should be retrieved - descending(bool,default=False): + descending(bool, default=False): False for descending True for ascending by price Returns: @@ -380,12 +380,8 @@ def peak_offers(self, good, sorted=True, descending=False, shuffled=True): def sell(self, receiver, good, quantity, price, currency='money', epsilon=epsilon): - """ commits to sell the quantity of good at price - - The good is not available for the agent. When the offer is - rejected it is automatically re-credited. When the offer is - accepted the money amount is credited. (partial acceptance - accordingly) + """ Sends a offer to sell a particular good to somebody. The amount promised + is reserved. (self.free(good), shows the not yet reserved goods) Args: receiver_group: @@ -433,17 +429,15 @@ def subround_2(self): price = 0 # makes sure the quantity is between zero and maximum available, but # if its only a little bit above or below its set to the bounds - available = self._haves[good] + available = self._inventory[good] assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) if quantity < 0: quantity = 0 - if quantity > available + epsilon + epsilon * max(quantity, available): - raise NotEnoughGoods(self.name, good, quantity - available) if quantity > available: quantity = available offer_id = self._offer_counter() - self._haves[good] -= quantity + self._inventory.reserve(good, quantity) offer = Offer(self.group, self.id, receiver[0], @@ -464,12 +458,8 @@ def subround_2(self): def buy(self, receiver, good, quantity, price, currency='money', epsilon=epsilon): - """ commits to sell the quantity of good at price - - The goods are not in haves or self.count(). When the offer is - rejected it is automatically re-credited. When the offer is - accepted the money amount is credited. (partial acceptance - accordingly) + """ Sends a offer to buy a particular good to somebody. The money promised + is reserved. (self.free(currency), shows the not yet reserved goods) Args: receiver: @@ -499,17 +489,15 @@ def buy(self, receiver, good, money_amount = quantity * price # makes sure the money_amount is between zero and maximum available, but # if its only a little bit above or below its set to the bounds - available = self._haves[currency] + available = self._inventory[currency] assert money_amount > - epsilon, '%s (price * quantity) %.30f is smaller than 0 - epsilon (%.30f)' % (currency, money_amount, - epsilon) if money_amount < 0: money_amount = 0 - if money_amount > available + epsilon + epsilon * max(money_amount, available): - raise NotEnoughGoods(self.name, currency, money_amount - available) if money_amount > available: money_amount = available offer_id = self._offer_counter() - self._haves[currency] -= money_amount + self._inventory.reserve(currency, money_amount) offer = Offer(self.group, self.id, receiver[0], @@ -570,24 +558,24 @@ def accept(self, offer, quantity=-999, epsilon=epsilon): if money_amount < 0: money_amount = 0 - available = self._haves[offer.currency] + available = self._inventory[offer.currency] if money_amount > available + epsilon + epsilon * max(money_amount, available): raise NotEnoughGoods(self.name, offer.currency, money_amount - available) if money_amount > available: money_amount = available - self._haves[offer.good] += quantity - self._haves[offer.currency] -= quantity * offer.price + self._inventory.haves[offer.good] += quantity + self._inventory.haves[offer.currency] -= quantity * offer.price else: assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) if quantity < 0: quantity = 0 - available = self._haves[offer.good] + available = self._inventory[offer.good] if quantity > available + epsilon + epsilon * max(quantity, available): raise NotEnoughGoods(self.name, offer.good, quantity - available) if quantity > available: quantity = available - self._haves[offer.good] -= quantity - self._haves[offer.currency] += quantity * offer.price + self._inventory.haves[offer.good] -= quantity + self._inventory.haves[offer.currency] += quantity * offer.price offer.final_quantity = quantity self._send(offer.sender_group, offer.sender_id, '_p', (offer.id, quantity)) del self._polled_offers[offer.id] @@ -642,11 +630,11 @@ def _receive_accept(self, offer_id_final_quantity): offer = self.given_offers[offer_id_final_quantity[0]] offer.final_quantity = offer_id_final_quantity[1] if offer.sell: - self._haves['money'] += offer.final_quantity * offer.price - self._haves[offer.good] += offer.quantity - offer.final_quantity + self._inventory.commit(offer.good, offer.quantity, offer.final_quantity) + self._inventory.haves[offer.currency] += offer.final_quantity * offer.price else: - self._haves[offer.good] += offer.final_quantity - self._haves['money'] += (offer.quantity - offer.final_quantity) * offer.price + self._inventory.haves[offer.good] += offer.final_quantity + self._inventory.commit(offer.currency, offer.quantity * offer.price, offer.final_quantity * offer.price) offer.status = "accepted" offer.status_round = self.round del self.given_offers[offer.id] @@ -673,9 +661,9 @@ def _receive_reject(self, offer_id): """ offer = self.given_offers[offer_id] if offer.sell: - self._haves[offer.good] += offer.quantity + self._inventory.rewind(offer.good, offer.quantity) else: - self._haves[offer.currency] += offer.quantity * offer.price + self._inventory.rewind(offer.currency, offer.quantity * offer.price) offer.status = "rejected" offer.status_round = self.round offer.final_quantity = 0 @@ -684,9 +672,9 @@ def _receive_reject(self, offer_id): def _delete_given_offer(self, offer_id): offer = self.given_offers.pop(offer_id) if offer.sell: - self._haves[offer.good] += offer.quantity + self._inventory.rewind(offer.good, offer.quantity) else: - self._haves[offer.currency] += offer.quantity * offer.price + self._inventory.rewind(offer.currency, offer.quantity * offer.price) def give(self, receiver, good, quantity, epsilon=epsilon): """ gives a good to another agent @@ -714,18 +702,18 @@ def give(self, receiver, good, quantity, epsilon=epsilon): Example:: - self.log('taxes', self.give('money': 0.05 * self.possession('money')) + self.log('taxes', self.give('money': 0.05 * self['money']) """ assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) if quantity < 0: quantity = 0 - available = self._haves[good] + available = self._inventory[good] if quantity > available + epsilon + epsilon * max(quantity, available): raise NotEnoughGoods(self.name, good, quantity - available) if quantity > available: quantity = available - self._haves[good] -= quantity + self._inventory.haves[good] -= quantity self._send(receiver[0], receiver[1], '_g', [good, quantity]) return {good: quantity} @@ -779,7 +767,7 @@ def _clearing__end_of_subround(self, incomming_messages): elif typ == '_r': self._receive_reject(msg) elif typ == '_g': - self._haves[msg[0]] += msg[1] + self._inventory.haves[msg[0]] += msg[1] elif typ == '_q': self._quotes[msg.id] = msg elif typ == '!o': @@ -792,10 +780,10 @@ def _clearing__end_of_subround(self, incomming_messages): self._contracts_deliver[contract.good][contract.id] = contract elif typ == '_dp': if msg.pay_group == self.group and msg.pay_id == self.id: - self._haves[msg.good] += msg.quantity + self._inventory[msg.good] += msg.quantity self._contracts_pay[msg.good][msg.id].delivered.append(self.round) else: - self._haves['money'] += msg.quantity * msg.price + self._inventory['money'] += msg.quantity * msg.price self._contracts_deliver[msg.good][msg.id].paid.append(self.round) elif typ == '!d': diff --git a/abce/trade.pyx b/abce/trade.pyx index d81a637a..9dab4176 100644 --- a/abce/trade.pyx +++ b/abce/trade.pyx @@ -70,6 +70,9 @@ cdef class Offer: receiver_id: this is the ID of the sender + currency: + The other good against which the good is traded. + good: the good offered or demanded @@ -77,7 +80,7 @@ cdef class Offer: the quantity offered or demanded price: - the suggested tansaction price + the suggested transaction price sell: this can have the values False for buy; True for sell @@ -203,7 +206,7 @@ cdef class Trade: try: self.accept(offer) except NotEnoughGoods: - self.accept(offer, self.possession('money') / offer.price) + self.accept(offer, self['money'] / offer.price) else: self.reject(offer) @@ -230,7 +233,7 @@ cdef class Trade: try: self.accept(offer) except NotEnoughGoods: - self.accept(offer, self.possession('money') / offer.price) + self.accept(offer, self['money'] / offer.price) else: self.reject(offer) @@ -375,7 +378,7 @@ cdef class Trade: Args: good: the good which should be retrieved - descending(bool,default=False): + descending(bool, default=False): False for descending True for ascending by price Returns: @@ -456,7 +459,7 @@ cdef class Trade: price = 0 # makes sure the quantity is between zero and maximum available, but # if its only a little bit above or below its set to the bounds - available = self._haves[good] + available = self._inventory[good] assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) if quantity < 0: quantity = 0 @@ -466,7 +469,7 @@ cdef class Trade: quantity = available offer_id = self._offer_counter() - self._haves[good] -= quantity + self._inventory.reserve(good, quantity) cdef Offer offer = Offer(self.group, self.id, receiver[0], @@ -524,17 +527,15 @@ cdef class Trade: money_amount = quantity * price # makes sure the money_amount is between zero and maximum available, but # if its only a little bit above or below its set to the bounds - available = self._haves[currency] + available = self._inventory[currency] assert money_amount > - epsilon, '%s (price * quantity) %.30f is smaller than 0 - epsilon (%.30f)' % (currency, money_amount, - epsilon) if money_amount < 0: money_amount = 0 - if money_amount > available + epsilon + epsilon * fmax(money_amount, available): - raise NotEnoughGoods(self.name, currency, money_amount - available) if money_amount > available: money_amount = available offer_id = self._offer_counter() - self._haves[currency] -= money_amount + self._inventory.reserve(currency, money_amount) cdef Offer offer = Offer(self.group, self.id, receiver[0], @@ -598,24 +599,24 @@ cdef class Trade: if money_amount < 0: money_amount = 0 - available = self._haves[offer.currency] + available = self._inventory[offer.currency] if money_amount > available + epsilon + epsilon * max(money_amount, available): raise NotEnoughGoods(self.name, offer.currency, money_amount - available) if money_amount > available: money_amount = available - self._haves[offer.good] += quantity - self._haves[offer.currency] -= quantity * offer.price + self._inventory.haves[offer.good] += quantity + self._inventory.haves[offer.currency] -= quantity * offer.price else: assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) if quantity < 0: quantity = 0 - available = self._haves[offer.good] + available = self._inventory[offer.good] if quantity > available + epsilon + epsilon * max(quantity, available): raise NotEnoughGoods(self.name, offer.good, quantity - available) if quantity > available: quantity = available - self._haves[offer.good] -= quantity - self._haves[offer.currency] += quantity * offer.price + self._inventory.haves[offer.good] -= quantity + self._inventory.haves[offer.currency] += quantity * offer.price offer.final_quantity = quantity self._send(offer.sender_group, offer.sender_id, '_p', (offer.id, quantity)) del self._polled_offers[offer.id] @@ -672,11 +673,11 @@ cdef class Trade: cdef Offer offer = self.given_offers[offer_id_final_quantity[0]] offer.final_quantity = offer_id_final_quantity[1] if offer.sell: - self._haves['money'] += offer.final_quantity * offer.price - self._haves[offer.good] += offer.quantity - offer.final_quantity + self._inventory.commit(offer.good, offer.quantity, offer.final_quantity) + self._inventory.haves[offer.currency] += offer.final_quantity * offer.price else: - self._haves[offer.good] += offer.final_quantity - self._haves['money'] += (offer.quantity - offer.final_quantity) * offer.price + self._inventory.haves[offer.good] += offer.final_quantity + self._inventory.commit(offer.currency, offer.quantity * offer.price, offer.final_quantity * offer.price) offer.status = "accepted" offer.status_round = self.round del self.given_offers[offer.id] @@ -703,9 +704,9 @@ cdef class Trade: """ cdef Offer offer = self.given_offers[offer_id] if offer.sell: - self._haves[offer.good] += offer.quantity + self._inventory.rewind(offer.good, offer.quantity) else: - self._haves[offer.currency] += offer.quantity * offer.price + self._inventory.rewind(offer.currency, offer.quantity * offer.price) offer.status = "rejected" offer.status_round = self.round offer.final_quantity = 0 @@ -714,9 +715,9 @@ cdef class Trade: def _delete_given_offer(self, offer_id): cdef Offer offer = self.given_offers.pop(offer_id) if offer.sell: - self._haves[offer.good] += offer.quantity + self._inventory.rewind(offer.good, offer.quantity) else: - self._haves[offer.currency] += offer.quantity * offer.price + self._inventory.rewind(offer.currency, offer.quantity * offer.price) def give(self, receiver, good, double quantity, double epsilon=epsilon): """ gives a good to another agent @@ -751,12 +752,12 @@ cdef class Trade: assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) if quantity < 0: quantity = 0 - available = self._haves[good] + available = self._inventory[good] if quantity > available + epsilon + epsilon * max(quantity, available): raise NotEnoughGoods(self.name, good, quantity - available) if quantity > available: quantity = available - self._haves[good] -= quantity + self._inventory.haves[good] -= quantity self._send(receiver[0], receiver[1], '_g', [good, quantity]) return {good: quantity} @@ -812,7 +813,7 @@ cdef class Trade: elif typ == '_r': self._receive_reject(msg) elif typ == '_g': - self._haves[msg[0]] += msg[1] + self._inventory.haves[msg[0]] += msg[1] elif typ == '_q': self._quotes[msg.id] = msg elif typ == '!o': @@ -825,10 +826,10 @@ cdef class Trade: self._contracts_deliver[contract.good][contract.id] = contract elif typ == '_dp': if msg.pay_group == self.group and msg.pay_id == self.id: - self._haves[msg.good] += msg.quantity + self._inventory[msg.good] += msg.quantity self._contracts_pay[msg.good][msg.id].delivered.append(self.round) else: - self._haves['money'] += msg.quantity * msg.price + self._inventory['money'] += msg.quantity * msg.price self._contracts_deliver[msg.good][msg.id].paid.append(self.round) elif typ == '!d': diff --git a/setup.py b/setup.py index d4622262..d245671f 100644 --- a/setup.py +++ b/setup.py @@ -60,7 +60,7 @@ def build_extension(self, ext): 'bokeh == 0.12.7'] -version = '0.9b1' +version = '0.9.1b0' setup(name='abce', diff --git a/unittest/buy.py b/unittest/buy.py index a9469fee..976971da 100644 --- a/unittest/buy.py +++ b/unittest/buy.py @@ -19,12 +19,12 @@ def one(self): """ if self.id % 2 == 0: self.create('money', random.uniform(0, 10000)) - self.money = self.possession('money') + self.money = self['money'] self.price = random.uniform(0.0001, 1) quantity = random.uniform(0, self.money / self.price) self.offer = self.buy(('buy', self.id + 1), 'cookies', quantity, self.price) - assert self.possession('money') == self.money - \ + assert self.free('money') == self.money - \ quantity * self.price def two(self): @@ -33,7 +33,7 @@ def two(self): """ if self.id % 2 == 1: self.create('cookies', random.uniform(0, 10000)) - cookies = self.possession('cookies') + cookies = self['cookies'] oo = self.get_offers('cookies') assert oo for offer in oo: @@ -42,21 +42,19 @@ def two(self): continue elif random.randint(0, 10) == 0: self.reject(offer) - assert self.possession('money') == 0 - assert self.possession('cookies') == cookies + assert self['money'] == 0 + assert self['cookies'] == cookies self.tests['rejected'] = True break # tests the automatic clean-up of polled offers try: self.accept(offer) - assert self.possession( - 'money') == offer.price * offer.quantity - assert self.possession( - 'cookies') == cookies - offer.quantity + assert self['money'] == offer.price * offer.quantity + assert self['cookies'] == cookies - offer.quantity self.tests['accepted'] = True except NotEnoughGoods: - self.accept(offer, self.possession('cookies')) - assert is_zero(self.possession('cookies')) - assert self.possession('money') == cookies * offer.price + self.accept(offer, self['cookies']) + assert is_zero(self['cookies']) + assert self['money'] == cookies * offer.price self.tests['partial'] = True def three(self): @@ -65,21 +63,21 @@ def three(self): if self.id % 2 == 0: offer = self.offer if offer.status == 'rejected': - test = self.money - self.possession('money') + test = self.money - self['money'] assert is_zero(test), test self.tests['rejected'] = True elif offer.status == 'accepted': if offer.final_quantity == offer.quantity: assert self.money - offer.quantity * \ - offer.price == self.possession('money') + offer.price == self['money'] - assert self.possession('cookies') == offer.quantity + assert self['cookies'] == offer.quantity self.tests['accepted'] = True else: test = (self.money - offer.final_quantity * - offer.price) - self.possession('money') + offer.price) - self['money'] assert is_zero(test), test - test = self.possession('cookies') - offer.final_quantity + test = self['cookies'] - offer.final_quantity assert is_zero(test), test self.tests['partial'] = True else: diff --git a/unittest/buyexpiringcapital.py b/unittest/buyexpiringcapital.py index bb830bc0..8c10451f 100644 --- a/unittest/buyexpiringcapital.py +++ b/unittest/buyexpiringcapital.py @@ -1,3 +1,4 @@ + from __future__ import division from __future__ import print_function import abce @@ -13,26 +14,26 @@ def one(self): self.create('money', 10) self.buy('buyexpiringcapital', 1, good='xcapital', quantity=10, price=1) - assert self.possession('xcapital') == 0 - assert self.possession('money') == 0 + assert self.free('xcapital') == 0 + assert self.free('money') == 0 def two(self): if self.id == 1: self.create('xcapital', 10) - assert self.possession('xcapital') == 10 - assert self.possession('money') == 0 + assert self['xcapital'] == 10 + assert self['money'] == 0 offer = self.get_offers('xcapital')[0] - self.possession('xcapital') == 10 + self['xcapital'] == 10 self.accept(offer) - assert self.possession('xcapital') == 0 - assert self.possession('money') == 10 + assert self['xcapital'] == 0 + assert self['money'] == 10 def three(self): if self.id == 0: - assert self.possession('xcapital') == 10 + assert self['xcapital'] == 10 self.destroy('xcapital', 10) elif self.id == 1: - assert self.possession('money') == 10 + assert self['money'] == 10 self.destroy('money', 10) def clean_up(self): diff --git a/unittest/contractbuyer.py b/unittest/contractbuyer.py index c3e76bd5..7d354f6c 100644 --- a/unittest/contractbuyer.py +++ b/unittest/contractbuyer.py @@ -1,7 +1,4 @@ -from __future__ import division -from __future__ import print_function import abce -from tools import * class ContractBuyer(abce.Agent, abce.Contracting): @@ -28,26 +25,26 @@ def accept_offer(self): def deliver(self): for contract in self.contracts_to_deliver('labor'): self.deliver_contract(contract) - assert self.possession('labor') == 0 + assert self['labor'] == 0 def pay(self): for contract in self.contracts_to_receive('labor'): if self.was_delivered_this_round(contract): self.create('money', 50) self.pay_contract(contract) - assert self.possession('money') == 0 + assert self['money'] == 0 def control(self): if self.id == 1: assert self.was_delivered_this_round( self.given_contract), self.given_contract - assert self.possession('money') == 0 - assert self.possession('labor') == 5 + assert self['money'] == 0 + assert self['labor'] == 5 else: assert self.was_paid_this_round( self.accepted_contract), self._contracts_payed - assert self.possession('labor') == 0, self.possession('labor') - assert self.possession('money') == 50, self.possession('money') + assert self['labor'] == 0, self['labor'] + assert self['money'] == 50, self['money'] self.destroy('money') def clean_up(self): diff --git a/unittest/contractbuyerstop.py b/unittest/contractbuyerstop.py index 43071767..39747743 100644 --- a/unittest/contractbuyerstop.py +++ b/unittest/contractbuyerstop.py @@ -1,7 +1,4 @@ -from __future__ import division -from __future__ import print_function import abce -from tools import * class ContractBuyerStop(abce.Agent, abce.Contracting): @@ -30,35 +27,35 @@ def accept_offer(self): def deliver(self): for contract in self.contracts_to_deliver('labor'): self.deliver_contract(contract) - assert self.possession('labor') == 0 + assert self['labor'] == 0 def pay(self): for contract in self.contracts_to_receive('labor'): if self.was_delivered_this_round(contract): self.create('money', 50) self.pay_contract(contract) - assert self.possession('money') == 0 + assert self['money'] == 0 def control(self): if self.round % 10 < 5: if self.id == 1: assert self.was_delivered_this_round( self.given_contract), self.given_contract - assert self.possession('money') == 0 - assert self.possession('labor') == 5 + assert self['money'] == 0 + assert self['labor'] == 5 else: assert self.was_paid_this_round( self.accepted_contract), self._contracts_payed - assert self.possession('labor') == 0, self.possession('labor') - assert self.possession('money') == 50, self.possession('money') + assert self['labor'] == 0, self['labor'] + assert self['money'] == 50, self['money'] self.destroy('money') else: if self.id == 1: - assert self.possession('money') == 0 - assert self.possession('labor') == 0 + assert self['money'] == 0 + assert self['labor'] == 0 else: - assert self.possession('labor') == 5, self.possession('labor') - assert self.possession('money') == 0, self.possession('money') + assert self['labor'] == 5, self['labor'] + assert self['money'] == 0, self['money'] self.destroy('labor') def clean_up(self): diff --git a/unittest/contractseller.py b/unittest/contractseller.py index d29a6064..336e35dd 100644 --- a/unittest/contractseller.py +++ b/unittest/contractseller.py @@ -1,7 +1,4 @@ -from __future__ import division -from __future__ import print_function import abce -from tools import * class ContractSeller(abce.Agent, abce.Contracting): @@ -28,28 +25,27 @@ def accept_offer(self): def deliver(self): for contract in self.contracts_to_deliver('labor'): self.deliver_contract(contract) - assert self.possession('labor') == 0 + assert self['labor'] == 0 def pay(self): for contract in self.contracts_to_receive('labor'): if self.was_delivered_this_round(contract): self.create('money', 50) self.pay_contract(contract) - assert self.possession('money') == 0 + assert self['money'] == 0 def control(self): if self.id == 0: assert self.was_paid_this_round( self.given_contract), self._contracts_payed - assert self.possession( - 'labor') == 0, (self.id, self.possession('labor')) - assert self.possession('money') == 50, self.possession('money') + assert self['labor'] == 0, (self.id, self['labor']) + assert self['money'] == 50, self['money'] self.destroy('money') else: assert self.was_delivered_this_round( self.accepted_contract), self.contracts_to_receive('labor') - assert self.possession('labor') == 5, self.possession('labor') - assert self.possession('money') == 0, self.possession('money') + assert self['labor'] == 5, self['labor'] + assert self['money'] == 0, self['money'] def clean_up(self): pass diff --git a/unittest/contractsellerstop.py b/unittest/contractsellerstop.py index f3b0f6a4..eb1d4e8b 100644 --- a/unittest/contractsellerstop.py +++ b/unittest/contractsellerstop.py @@ -1,7 +1,4 @@ -from __future__ import division -from __future__ import print_function import abce -from tools import * class ContractSellerStop(abce.Agent, abce.Contracting): @@ -30,38 +27,36 @@ def accept_offer(self): def deliver(self): for contract in self.contracts_to_deliver('labor'): self.deliver_contract(contract) - assert self.possession('labor') == 0 + assert self['labor'] == 0 def pay(self): for contract in self.contracts_to_receive('labor'): if self.was_delivered_this_round(contract): self.create('money', 50) self.pay_contract(contract) - assert self.possession('money') == 0 + assert self['money'] == 0 def control(self): if self.round % 10 < 5: if self.id == 0: assert self.was_paid_this_round( self.given_contract), self._contracts_payed - assert self.possession( - 'labor') == 0, (self.id, self.possession('labor')) - assert self.possession('money') == 50, self.possession('money') + assert self['labor'] == 0, (self.id, self['labor']) + assert self['money'] == 50, self['money'] self.destroy('money') else: assert self.was_delivered_this_round( self.accepted_contract), self.contracts_to_receive('labor') - assert self.possession('labor') == 5, self.possession('labor') - assert self.possession('money') == 0, self.possession('money') + assert self['labor'] == 5, self['labor'] + assert self['money'] == 0, self['money'] else: if self.id == 0: - assert self.possession( - 'labor') == 5, (self.id, self.possession('labor')) - assert self.possession('money') == 0, self.possession('money') + assert self['labor'] == 5, (self.id, self['labor']) + assert self['money'] == 0, self['money'] self.destroy('labor') else: - assert self.possession('labor') == 0, self.possession('labor') - assert self.possession('money') == 0, self.possession('money') + assert self['labor'] == 0, self['labor'] + assert self['money'] == 0, self['money'] def clean_up(self): pass diff --git a/unittest/endowment.py b/unittest/endowment.py index de428455..69c1ed88 100644 --- a/unittest/endowment.py +++ b/unittest/endowment.py @@ -1,7 +1,4 @@ -from __future__ import division -from __future__ import print_function import abce -from tools import * class Endowment(abce.Agent, abce.Household): @@ -13,13 +10,13 @@ def init(self, simulation_parameters, agent_parameters): self.set_cobb_douglas_utility_function({'milk': 2}) def Iconsume(self): - assert self.possession('labor') == 5, self.possession('labor') - assert self.possession('milk') == 10 + (self.round - self.creation) * (10 - 3), (10 + ( - self.round - self.creation) * (10 - 3), self.possession('milk'), self.creation) - milk = self.possession('milk') + assert self['labor'] == 5, self['labor'] + assert self['milk'] == 10 + (self.round - self.creation) * (10 - 3), (10 + ( + self.round - self.creation) * (10 - 3), self['milk'], self.creation) + milk = self['milk'] utility = self.consume({'milk': 3}) assert utility == 9, utility - assert milk - 3 == self.possession('milk'), self.possession('milk') + assert milk - 3 == self['milk'], self['milk'] def all_tests_completed(self): if self.round == self.last_round and self.id == 0: diff --git a/unittest/expiringcapital.py b/unittest/expiringcapital.py index c5e6fb25..a74cc312 100644 --- a/unittest/expiringcapital.py +++ b/unittest/expiringcapital.py @@ -25,17 +25,17 @@ def go(self): self.create('xcapital', 10) if self.round == 0: - assert self.possession('xcapital') == 1 + assert self['xcapital'] == 1 if self.round == 1: - assert self.possession('xcapital') == 1 + assert self['xcapital'] == 1 if self.round == 2: - assert self.possession('xcapital') == 11 + assert self['xcapital'] == 11 if self.round == 3: - assert self.possession('xcapital') == 11 + assert self['xcapital'] == 11 if self.round == 4: - assert self.possession('xcapital') == 11 + assert self['xcapital'] == 11 if self.round == 5: - assert self.possession('xcapital') == 10 + assert self['xcapital'] == 10 def clean_up(self): pass diff --git a/unittest/give.py b/unittest/give.py index 2e987d30..a9c3f686 100644 --- a/unittest/give.py +++ b/unittest/give.py @@ -1,7 +1,4 @@ -from __future__ import division -from __future__ import print_function import abce -from tools import * import random @@ -16,10 +13,10 @@ def init(self, simulation_parameters, agent_parameters): def one(self): if self.id == 0: self.create('cookies', random.uniform(0, 10000)) - self.cookies = self.possession('cookies') - quantity = random.uniform(0, self.possession('cookies')) + self.cookies = self['cookies'] + quantity = random.uniform(0, self['cookies']) self.give(('give', 1), 'cookies', quantity) - assert self.possession('cookies') == self.cookies - quantity + assert self['cookies'] == self.cookies - quantity self.send(('give', 1), topic='tpc', content=quantity) def two(self): @@ -35,7 +32,7 @@ def two(self): self.tests['topic'] = True assert len(msg) == 1, len(msg) msg = msg[0] - assert msg.content == self.possession('cookies') + assert msg.content == self['cookies'] assert msg.sender == ('give', 0), msg.sender assert msg.topic == 'tpc' assert msg.receiver == ('give', 1) diff --git a/unittest/giveexpiringcapital.py b/unittest/giveexpiringcapital.py index 1dbbccaf..b33a0251 100644 --- a/unittest/giveexpiringcapital.py +++ b/unittest/giveexpiringcapital.py @@ -1,5 +1,4 @@ -from __future__ import division -from __future__ import print_function + import abce from abce.agents import Firm @@ -9,24 +8,19 @@ def init(self, simulation_parameters, _,): self.last_round = simulation_parameters['rounds'] - 1 if self.id == 0: self.create('xcapital', 10) - assert self.possession( - 'xcapital') == 10, self.possession('xcapital') + assert self['xcapital'] == 10, self['xcapital'] def one(self): if self.id == 0: - assert self.possession( - 'xcapital') == 10, self.possession('xcapital') + assert self['xcapital'] == 10, self['xcapital'] self.give('giveexpiringcapital', 1, 'xcapital', 10) - assert self.possession( - 'xcapital') == 0, self.possession('xcapital') + assert self['xcapital'] == 0, self['xcapital'] def two(self): if self.id == 1: - assert self.possession( - 'xcapital') == 10, self.possession('xcapital') + assert self['xcapital'] == 10, self['xcapital'] self.give('giveexpiringcapital', 0, 'xcapital', 10) - assert self.possession( - 'xcapital') == 0, self.possession('xcapital') + assert self['xcapital'] == 0, self['xcapital'] def three(self): pass diff --git a/unittest/production_firm.py b/unittest/production_firm.py index 1d862193..8bf3c79e 100644 --- a/unittest/production_firm.py +++ b/unittest/production_firm.py @@ -1,5 +1,3 @@ -from __future__ import division -from __future__ import print_function import abce from tools import is_zero from abce.agents import Firm @@ -51,10 +49,9 @@ def production(self): self.create('b', 2) self.produce({'a': 1, 'b': 2}) - assert self.possession('a') == 1, self.possession('a') - assert self.possession('b') == 1.8, self.possession('b') - assert self.possession( - 'consumption_good') == 1 ** 0.5 * 2, self.possession('consumption_good') + assert self['a'] == 1, self['a'] + assert self['b'] == 1.8, self['b'] + assert self['consumption_good'] == 1 ** 0.5 * 2, self['consumption_good'] self.destroy('a', 1) self.destroy('b', 1.8) self.destroy('consumption_good', 1 ** 0.5 * 2) @@ -75,10 +72,10 @@ def production(self): self.create('b', 2) self.produce({'a': 1, 'b': 2}) - assert self.possession('a') == 1, self.possession('a') - assert self.possession('b') == 0, self.possession('b') - assert self.possession('consumption_good') == 5 * \ - 1 ** 2 * 2 ** 1, self.possession('consumption_good') + assert self['a'] == 1, self['a'] + assert self['b'] == 0, self['b'] + assert self['consumption_good'] == 5 * \ + 1 ** 2 * 2 ** 1, self['consumption_good'] self.destroy('a', 1) self.destroy('consumption_good', 5 * 1 ** 2 * 2 ** 1) @@ -87,10 +84,10 @@ def production(self): self.create('b', 2) self.produce({'a': 1, 'b': 2}) - assert self.possession('a') == 1, self.possession('a') - assert self.possession('b') == 0, self.possession('b') - assert self.possession('consumption_good') == min( - 1 * 3, 2 * 1), self.possession('consumption_good') + assert self['a'] == 1, self['a'] + assert self['b'] == 0, self['b'] + assert self['consumption_good'] == min( + 1 * 3, 2 * 1), self['consumption_good'] self.destroy('a', 1) self.destroy('consumption_good', min(1 * 3, 2 * 1)) @@ -100,14 +97,12 @@ def production(self): self.create('c', 10) self.produce({'a': 1, 'b': 2, 'c': 5}) - assert self.possession('a') == 9, self.possession('a') - assert self.possession('b') == 9.8, self.possession('b') - assert self.possession('c') == 10, self.possession('c') - assert self.possession( - 'soft_rubber') == 1 ** 0.25 * 2 ** 0.5 * 5 ** 0.25 - assert self.possession( - 'hard_rubber') == 1 ** 0.1 * 2 ** 0.2 * 5 ** 0.01 - assert self.possession('waste') == 2 / 2, self.possession('waste') + assert self['a'] == 9, self['a'] + assert self['b'] == 9.8, self['b'] + assert self['c'] == 10, self['c'] + assert self['soft_rubber'] == 1 ** 0.25 * 2 ** 0.5 * 5 ** 0.25 + assert self['hard_rubber'] == 1 ** 0.1 * 2 ** 0.2 * 5 ** 0.01 + assert self['waste'] == 2 / 2, self['waste'] self.destroy('a') self.destroy('b') self.destroy('c') @@ -127,13 +122,13 @@ def production(self): self.create('c', 4) self.produce({'a': 1, 'b': 2, 'c': 4}) - assert self.possession('a') == 1, self.possession('a') - assert self.possession('b') == 0, self.possession('b') - assert self.possession('c') == 0, self.possession('c') + assert self['a'] == 1, self['a'] + assert self['b'] == 0, self['b'] + assert self['c'] == 0, self['c'] expected = (0.25 * 1 ** 0.5 + 0.25 * 2 ** 0.5 + 0.5 * 4 ** 0.5) ** (1 / 0.5) - assert self.possession('consumption_good') == expected, (self.possession( - 'consumption_good'), expected) + assert self['consumption_good'] == expected, (self[ + 'consumption_good'], expected) self.destroy('a', 1) self.destroy('consumption_good', expected) @@ -145,15 +140,14 @@ def production(self): self.create('e', 2) self.produce({'a': 1, 'b': 2, 'c': 2, 'd': 2, 'e': 2}) - assert self.possession('a') == 1, self.possession('a') - assert self.possession('b') == 0, self.possession('b') - assert self.possession('c') == 0, self.possession('c') - assert self.possession('d') == 0, self.possession('d') - assert self.possession('e') == 0, self.possession('e') + assert self['a'] == 1, self['a'] + assert self['b'] == 0, self['b'] + assert self['c'] == 0, self['c'] + assert self['d'] == 0, self['d'] + assert self['e'] == 0, self['e'] expected = 2 * (0.2 * 1 ** 0.5 + 0.2 * 2 ** 0.5 + 0.2 * 2 ** 0.5 + 0.2 * 2 ** 0.5 + 0.2 * 2 ** 0.5) ** (1 / 0.5) - assert is_zero(self.possession('consumption_good') - expected), (self.possession( - 'consumption_good'), expected) + assert is_zero(self['consumption_good'] - expected), (self['consumption_good'], expected) self.destroy('a', 1) self.destroy('consumption_good', expected) diff --git a/unittest/production_multifirm.py b/unittest/production_multifirm.py index 39fd4883..cd0945cc 100644 --- a/unittest/production_multifirm.py +++ b/unittest/production_multifirm.py @@ -1,3 +1,4 @@ + from __future__ import division from __future__ import print_function import abce @@ -48,10 +49,10 @@ def production(self): self.create('b', 2) self.produce(self.pf, {'a': 1, 'b': 2}) - assert self.possession('a') == 1, self.possession('a') - assert self.possession('b') == 1.8, self.possession('b') - assert is_zero(self.possession('consumption_good') - 1. ** 0.5 * 2), \ - self.possession('consumption_good') + assert self['a'] == 1, self['a'] + assert self['b'] == 1.8, self['b'] + assert is_zero(self['consumption_good'] - 1. ** 0.5 * 2), \ + self['consumption_good'] self.destroy('a') self.destroy('b') self.destroy('consumption_good') @@ -71,10 +72,10 @@ def production(self): self.create('b', 2) self.produce(self.cd, {'a': 1, 'b': 2}) - assert self.possession('a') == 1, self.possession('a') - assert self.possession('b') == 0, self.possession('b') - assert self.possession('consumption_good') == 5 * \ - 1 ** 2 * 2 ** 1, self.possession('consumption_good') + assert self['a'] == 1, self['a'] + assert self['b'] == 0, self['b'] + assert self['consumption_good'] == 5 * \ + 1 ** 2 * 2 ** 1, self['consumption_good'] self.destroy('a') self.destroy('b') self.destroy('consumption_good') @@ -83,10 +84,10 @@ def production(self): self.create('b', 2) self.produce(self.leontief, {'a': 1, 'b': 2}) - assert self.possession('a') == 1, self.possession('a') - assert self.possession('b') == 0, self.possession('b') - assert self.possession('consumption_good') == min( - 1 * 3, 2 * 1), self.possession('consumption_good') + assert self['a'] == 1, self['a'] + assert self['b'] == 0, self['b'] + assert self['consumption_good'] == min( + 1 * 3, 2 * 1), self['consumption_good'] self.destroy('a') self.destroy('consumption_good') @@ -95,14 +96,14 @@ def production(self): self.create('c', 10) self.produce(self.many_goods_pf, {'a': 1, 'b': 2, 'c': 5}) - assert self.possession('a') == 9, self.possession('a') - assert self.possession('b') == 9.8, self.possession('b') - assert self.possession('c') == 10, self.possession('c') - assert self.possession('soft_rubber') == 1 ** 0.25 * \ - 2 ** 0.5 * 5 ** 0.25, self.possession('soft_rubber') - assert self.possession('hard_rubber') == 1 ** 0.1 * \ - 2 ** 0.2 * 5 ** 0.01, self.possession('hard_rubber') - assert self.possession('waste') == 2 / 2, self.possession('waste') + assert self['a'] == 9, self['a'] + assert self['b'] == 9.8, self['b'] + assert self['c'] == 10, self['c'] + assert self['soft_rubber'] == 1 ** 0.25 * \ + 2 ** 0.5 * 5 ** 0.25, self['soft_rubber'] + assert self['hard_rubber'] == 1 ** 0.1 * \ + 2 ** 0.2 * 5 ** 0.01, self['hard_rubber'] + assert self['waste'] == 2 / 2, self['waste'] self.destroy('a') self.destroy('b') self.destroy('c') @@ -120,13 +121,13 @@ def production(self): self.create('c', 4) self.produce(self.ces, {'a': 1, 'b': 2, 'c': 4}) - assert self.possession('a') == 1, self.possession('a') - assert self.possession('b') == 0, self.possession('b') - assert self.possession('c') == 0, self.possession('c') + assert self['a'] == 1, self['a'] + assert self['b'] == 0, self['b'] + assert self['c'] == 0, self['c'] expected = (0.25 * 1 ** 0.5 + 0.25 * 2 ** 0.5 + 0.5 * 4 ** 0.5) ** (1 / 0.5) - assert self.possession('consumption_good') == expected, ( - self.possession('consumption_good'), expected) + assert self['consumption_good'] == expected, ( + self['consumption_good'], expected) self.destroy('a', 1) self.destroy('consumption_good', expected) @@ -138,16 +139,16 @@ def production(self): self.produce(self.ces_flexible, { 'a': 1, 'b': 2, 'c': 2, 'd': 2, 'e': 2}) - assert self.possession('a') == 1, self.possession('a') - assert self.possession('b') == 0, self.possession('b') - assert self.possession('c') == 0, self.possession('c') - assert self.possession('d') == 0, self.possession('d') - assert self.possession('e') == 0, self.possession('e') + assert self['a'] == 1, self['a'] + assert self['b'] == 0, self['b'] + assert self['c'] == 0, self['c'] + assert self['d'] == 0, self['d'] + assert self['e'] == 0, self['e'] expected = (2 * (0.2 * 1 ** 0.5 + 0.2 * 2 ** 0.5 + 0.2 * 2 ** 0.5 + 0.2 * 2 ** 0.5 + 0.2 * 2 ** 0.5) ** (1 / 0.5)) - assert is_zero(self.possession('consumption_good') - expected), ( - self.possession('consumption_good'), expected) + assert is_zero(self['consumption_good'] - expected), ( + self['consumption_good'], expected) self.destroy('a', 1) self.destroy('consumption_good', expected) diff --git a/unittest/quote_buy.py b/unittest/quote_buy.py index a412d0f2..a380b3b6 100644 --- a/unittest/quote_buy.py +++ b/unittest/quote_buy.py @@ -1,7 +1,5 @@ -from __future__ import division -from __future__ import print_function import abce -from tools import * +from tools import is_zero import random @@ -18,7 +16,7 @@ def one(self): """ if self.id == 0: self.create('money', random.uniform(0, 10000)) - self.money = self.possession('money') + self.money = self['money'] self.price = random.uniform(0.0001, 1) quantity = random.uniform(0, self.money / self.price) self.quote_buy('quotebuy', 1, 'cookies', quantity, self.price) @@ -29,7 +27,7 @@ def two(self): """ if self.id == 1: self.create('cookies', random.uniform(0, 10000)) - cookies = self.possession('cookies') + cookies = self['cookies'] if random.randint(0, 1) == 0: quotes = self.get_quotes('cookies') else: @@ -40,16 +38,15 @@ def two(self): if random.randint(0, 1) == 0: self.tests['not_answered'] = True continue - if self.possession('cookies') >= quote['quantity']: + if self['cookies'] >= quote['quantity']: self.accept_quote(quote) self.final_money = quote['price'] * quote['quantity'] - assert self.possession( - 'cookies') == cookies - quote['quantity'] + assert self['cookies'] == cookies - quote['quantity'] self.tests['accepted'] = True else: self.accept_quote_partial( - quote, self.possession('cookies')) - assert is_zero(self.possession('cookies')) + quote, self['cookies']) + assert is_zero(self['cookies']) self.final_money = cookies * quote['price'] self.tests['partial'] = True @@ -65,7 +62,7 @@ def clean_up(self): self.destroy_all('money') self.destroy_all('cookies') if self.id == 1: - self.final_money = self.possession('money') + self.final_money = self['money'] def all_tests_completed(self): if self.round == self.last_round and self.id == 1: diff --git a/unittest/sell.py b/unittest/sell.py index e69349de..56c00568 100644 --- a/unittest/sell.py +++ b/unittest/sell.py @@ -1,5 +1,5 @@ import abce -from tools import * +from tools import is_zero import random from abce import NotEnoughGoods @@ -15,17 +15,17 @@ def init(self, simulation_parameters, agent_parameters): def one(self): if self.id % 2 == 0: self.create('cookies', random.uniform(0, 10000)) - self.cookies = self.possession('cookies') + self.cookies = self['cookies'] self.price = random.uniform(0.0001, 1) quantity = random.uniform(0, self.cookies) self.offer = self.sell(receiver=('sell', self.id + 1), good='cookies', quantity=quantity, price=self.price) - assert self.possession('cookies') == self.cookies - quantity + assert self.free('cookies') == self.cookies - quantity def two(self): if self.id % 2 == 1: self.create('money', random.uniform(0, 10000)) - money = self.possession('money') + money = self['money'] oo = self.get_offers('cookies') assert oo, oo for offer in oo: @@ -34,30 +34,27 @@ def two(self): continue elif random.randrange(0, 10) == 0: self.reject(offer) - assert self.possession('money') == money - assert self.possession('cookies') == 0 + assert self['money'] == money + assert self['cookies'] == 0 self.tests['rejected'] = True break # tests the automatic clean-up of polled offers try: if random.randrange(2) == 0: self.accept(offer) - assert self.possession('cookies') == offer.quantity - assert self.possession( - 'money') == money - offer.quantity * offer.price + assert self['cookies'] == offer.quantity + assert self['money'] == money - offer.quantity * offer.price self.tests['accepted'] = True else: self.accept(offer, offer.quantity) - assert self.possession('cookies') == offer.quantity - assert self.possession( - 'money') == money - offer.quantity * offer.price + assert self['cookies'] == offer.quantity + assert self['money'] == money - offer.quantity * offer.price self.tests['full_partial'] = True except NotEnoughGoods: - self.accept(offer, self.possession('money') / offer.price) - assert self.possession( - 'money') < 0.00000001, self.possession('money') - test = (self.possession('money') - money) - \ - self.possession('cookies') / offer.price + self.accept(offer, self['money'] / offer.price) + assert self['money'] < 0.00000001, self['money'] + test = (self['money'] - money) - \ + self['cookies'] / offer.price assert test < 0.00000001, test self.tests['partial'] = True @@ -65,20 +62,19 @@ def three(self): if self.id % 2 == 0: offer = self.offer if offer.status == 'rejected': - assert is_zero(self.cookies - self.possession('cookies')) + assert is_zero(self.cookies - self['cookies']) self.tests['rejected'] = True elif offer.status == 'accepted': if offer.final_quantity == offer.quantity: assert self.cookies - \ - offer.quantity == self.possession('cookies') - assert self.possession( - 'money') == offer.quantity * offer.price + offer.quantity == self['cookies'] + assert self['money'] == offer.quantity * offer.price self.tests['accepted'] = True else: test = (self.cookies - offer.final_quantity) - \ - self.possession('cookies') + self['cookies'] assert is_zero(test), test - test = self.possession('money') - \ + test = self['money'] - \ offer.final_quantity * offer.price assert is_zero(test), test self.tests['partial'] = True diff --git a/unittest/start.py b/unittest/start.py index 5e8f233e..8a4b3da8 100644 --- a/unittest/start.py +++ b/unittest/start.py @@ -4,24 +4,30 @@ import start_delete_create if __name__ == '__main__': + print("Logging test, 1 core") start_logging_test.main(processes=1) print('Iteration of logger testing with 1 core finished') if (platform.system() != 'Windows' and platform.python_implementation() != 'PyPy'): + print("Logging test, 4 cores") start_logging_test.main(processes=4) print('Iteration of logger testing with multiple processes finished') + print("Core engine, 1 core") start_core_engine.main(processes=1, rounds=50) print('Iteration with 1 core finished') if (platform.system() != 'Windows' and platform.python_implementation() != 'PyPy'): + print("Core engine, 4 cores") start_core_engine.main(processes=4, rounds=50) print('Iteration with multiple processes finished') + print("Create/delete, 1 core") start_delete_create.main(processes=1, rounds=30) print('Iteration with 1 core finished') - if (platform.system() != 'Windows'): + if (platform.system() != 'Windows' and platform.python_implementation() != 'PyPy'): + print("Create/delete, 4 cores") start_delete_create.main(processes=4, rounds=20) print('Iteration with multiple processes finished') diff --git a/unittest/utility_household.py b/unittest/utility_household.py index 08707aa5..d3f5bdc0 100644 --- a/unittest/utility_household.py +++ b/unittest/utility_household.py @@ -1,7 +1,5 @@ -from __future__ import division -from __future__ import print_function import abce -from tools import * +from tools import is_zero class UtilityHousehold(abce.Agent, abce.Household): @@ -39,9 +37,9 @@ def consumption(self): self.create('c', 10) utility = self.consume({'a': 5, 'b': 3, 'c': 1}) assert utility == max(5 ** 0.2, 3 ** 0.5 * 1 ** 0.3), utility - assert self.possession('a') == 5 - assert self.possession('b') == 9.7 - assert self.possession('c') == 10 + assert self['a'] == 5 + assert self['b'] == 9.7 + assert self['c'] == 10 self.destroy('a') self.destroy('b') self.destroy('c') @@ -52,13 +50,13 @@ def consumption(self): self.create('c', 10) utility = self.consume({'a': 5, 'b': 3, 'c': 1}) assert utility == 5 ** 0.2 * 3 ** 0.5 * 1 ** 0.3, utility - assert self.possession('a') == 5 - assert self.possession('b') == 7 - assert self.possession('c') == 9 + assert self['a'] == 5 + assert self['b'] == 7 + assert self['c'] == 9 self.consume_everything() - assert self.possession('a') == 0 - assert self.possession('b') == 0 - assert self.possession('c') == 0 + assert self['a'] == 0 + assert self['b'] == 0 + assert self['c'] == 0 pu = self.predict_utility({'a': 5, 'b': 300, 'c': 10}) assert pu == 5 ** 0.2 * 300 ** 0.5 * 10 ** 0.3 @@ -70,9 +68,9 @@ def consumption(self): utility = self.consume_everything() assert is_zero(utility - max(10 ** 0.2, 10 ** 0.5 * 10 ** 0.3) ), (utility, max(10 ** 0.2, 10 ** 0.5 * 10 ** 0.3)) - assert self.possession('a') == 0 - assert self.possession('b') == 9 - assert self.possession('c') == 10 + assert self['a'] == 0 + assert self['b'] == 9 + assert self['c'] == 10 self.destroy('a') self.destroy('b') self.destroy('c') @@ -84,9 +82,9 @@ def consumption(self): utility = self.consume_everything() assert is_zero(utility - 10 ** 0.2 * 10 ** 0.5 * 10 ** 0.3), (utility, 10 ** 0.2 * 10 ** 0.5 * 10 ** 0.3) - assert self.possession('a') == 0 - assert self.possession('b') == 0 - assert self.possession('c') == 0 + assert self['a'] == 0 + assert self['b'] == 0 + assert self['c'] == 0 pu = self.predict_utility({'a': 5, 'b': 300, 'c': 10}) assert pu == 5 ** 0.2 * 300 ** 0.5 * 10 ** 0.3 From 641bae49a1de331b2e72c8e9a24fc0b2b065b441 Mon Sep 17 00:00:00 2001 From: DavoudTaghawiNejad Date: Mon, 11 Sep 2017 03:26:05 -0300 Subject: [PATCH 7/8] Rename free to not_reserved --- abce/agent.py | 6 +++--- abce/inventory.py | 43 +++++++++++++++++++++++++++++++------------ unittest/buy.py | 2 +- unittest/sell.py | 2 +- 4 files changed, 36 insertions(+), 17 deletions(-) diff --git a/abce/agent.py b/abce/agent.py index f54dfef4..a9d54247 100644 --- a/abce/agent.py +++ b/abce/agent.py @@ -180,7 +180,7 @@ def possession(self, good): self.bancrupcy = True """ - print("depreciated use self[good]") + print("depreciated use self[good] or self.not_reserved[good]") return self._inventory[good] def possessions(self): @@ -294,8 +294,8 @@ def _declare_expiring(self, good, duration): """ self._inventory._declare_expiring(good, duration) - def free(self, good): - return self._inventory.free(good) + def not_reserved(self, good): + return self._inventory.not_reserved(good) def destroy(self, good, quantity=None): """ destroys quantity of the good. If quantity is omitted destroys all diff --git a/abce/inventory.py b/abce/inventory.py index 1bfe28a7..8892467a 100644 --- a/abce/inventory.py +++ b/abce/inventory.py @@ -10,7 +10,7 @@ class Inventory(object): def __init__(self, name): self.haves = defaultdict(int) - self.committed = defaultdict(int) + self.reserved = defaultdict(int) self.name = name self._expiring_goods = [] self._perishable = [] @@ -83,16 +83,16 @@ def destroy(self, good, quantity=None): self.haves[good] -= quantity def reserve(self, good, quantity): - self.committed[good] += quantity - if self.committed[good] > self.haves[good]: - self.committed[good] += quantity - raise NotEnoughGoods(self.name, good, quantity - (self.haves[good] - self.committed[good])) + self.reserved[good] += quantity + if self.reserved[good] > self.haves[good]: + self.reserved[good] += quantity + raise NotEnoughGoods(self.name, good, quantity - (self.haves[good] - self.reserved[good])) def rewind(self, good, quantity): - self.committed[good] -= quantity + self.reserved[good] -= quantity def commit(self, good, committed_quantity, final_quantity): - self.committed[good] -= committed_quantity + self.reserved[good] -= committed_quantity self.haves[good] -= final_quantity def transform(self, ingredient, unit, product, quantity=None): @@ -102,10 +102,9 @@ def transform(self, ingredient, unit, product, quantity=None): self.create(product, float(unit) * quantity) def possession(self, good): - print('possession depreciated') - return self.free(good) + return self.not_reserved(good) - def free(self, good): + def not_reserved(self, good): """ returns how much of good an agent possesses. Returns: @@ -123,11 +122,31 @@ def free(self, good): self.bankruptcy = True """ - return float(self.haves[good] - self.committed[good]) + return float(self.haves[good] - self.reserved[good]) + + def reserved(self, good): + """ returns how much of a good an agent has currently reseed to sell or buy. + + Returns: + A number. + + possession does not return a dictionary for self.log(...), you can use self.possessions([...]) + (plural) with self.log. + + Example:: + + if self['money'] < 1: + self.financial_crisis = True + + if not(is_positive(self['money']): + self.bankruptcy = True + + """ + return self.reserved[good] def possessions(self): """ returns all possessions """ - return {good: float(self.haves[good] - self.committed[good]) for good in self.haves} + return {good: float(self.haves[good] - self.reserved[good]) for good in self.haves} def calculate_netvalue(self, prices): return sum(quantity * prices[name] diff --git a/unittest/buy.py b/unittest/buy.py index 976971da..de10c2c2 100644 --- a/unittest/buy.py +++ b/unittest/buy.py @@ -24,7 +24,7 @@ def one(self): quantity = random.uniform(0, self.money / self.price) self.offer = self.buy(('buy', self.id + 1), 'cookies', quantity, self.price) - assert self.free('money') == self.money - \ + assert self.not_reserved('money') == self.money - \ quantity * self.price def two(self): diff --git a/unittest/sell.py b/unittest/sell.py index 56c00568..8db3733c 100644 --- a/unittest/sell.py +++ b/unittest/sell.py @@ -20,7 +20,7 @@ def one(self): quantity = random.uniform(0, self.cookies) self.offer = self.sell(receiver=('sell', self.id + 1), good='cookies', quantity=quantity, price=self.price) - assert self.free('cookies') == self.cookies - quantity + assert self.not_reserved('cookies') == self.cookies - quantity def two(self): if self.id % 2 == 1: From 1c06264b1b59cf83608111bba457cf3a07beedd7 Mon Sep 17 00:00:00 2001 From: DavoudTaghawiNejad Date: Mon, 11 Sep 2017 08:19:43 -0300 Subject: [PATCH 8/8] Directly access self.inventroy.haves[good] --- abce/agent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abce/agent.py b/abce/agent.py index a9d54247..9c6da4b7 100644 --- a/abce/agent.py +++ b/abce/agent.py @@ -360,7 +360,7 @@ def _send(self, receiver_group, receiver_id, typ, msg): (receiver_group, receiver_id, (typ, msg))) def __getitem__(self, good): - return self._inventory[good] + return self._inventory.haves[good] def __del__(self): self._check_for_lost_messages()