diff --git a/abce/trade.c b/abce/trade.c index d160dbfc..57c5c043 100644 --- a/abce/trade.c +++ b/abce/trade.c @@ -1,4 +1,4 @@ -/* Generated by Cython 0.28.2 */ +/* Generated by Cython 0.28.3 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -7,7 +7,7 @@ #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_28_2" +#define CYTHON_ABI "0_28_3" #define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof @@ -453,6 +453,7 @@ static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { #define PyString_Type PyUnicode_Type #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact + #define PyObject_Unicode PyObject_Str #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) @@ -645,7 +646,7 @@ static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) -#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) +static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); #define __Pyx_PySequence_Tuple(obj)\ @@ -753,7 +754,7 @@ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; -static PyObject *__pyx_cython_runtime; +static PyObject *__pyx_cython_runtime = NULL; static PyObject *__pyx_empty_tuple; static PyObject *__pyx_empty_bytes; static PyObject *__pyx_empty_unicode; @@ -1249,7 +1250,6 @@ int __pyx_module_is_main_trade = 0; static PyObject *__pyx_builtin_super; static PyObject *__pyx_builtin_AssertionError; static const char __pyx_k_id[] = "id"; -static const char __pyx_k_buy[] = "buy"; static const char __pyx_k_doc[] = "__doc__"; static const char __pyx_k_key[] = "key"; static const char __pyx_k_new[] = "new"; @@ -1257,6 +1257,7 @@ static const char __pyx_k_off[] = "off"; static const char __pyx_k_pop[] = "pop"; static const char __pyx_k_put[] = "put"; static const char __pyx_k_ret[] = "ret"; +static const char __pyx_k_args[] = "args"; static const char __pyx_k_give[] = "give"; static const char __pyx_k_good[] = "good"; static const char __pyx_k_init[] = "__init__"; @@ -1284,6 +1285,7 @@ static const char __pyx_k_trade[] = "trade"; static const char __pyx_k_accept[] = "accept"; static const char __pyx_k_commit[] = "commit"; static const char __pyx_k_import[] = "__import__"; +static const char __pyx_k_kwargs[] = "kwargs"; static const char __pyx_k_module[] = "__module__"; static const char __pyx_k_quotes[] = "_quotes"; static const char __pyx_k_random[] = "random"; @@ -1302,6 +1304,9 @@ static const char __pyx_k_reverse[] = "reverse"; static const char __pyx_k_shuffle[] = "shuffle"; static const char __pyx_k_accepted[] = "accepted"; static const char __pyx_k_currency[] = "currency"; +static const char __pyx_k_get_bids[] = "get_bids"; +static const char __pyx_k_get_take[] = "get_take"; +static const char __pyx_k_make_bid[] = "make_bid"; static const char __pyx_k_offer_id[] = "offer_id"; static const char __pyx_k_qualname[] = "__qualname__"; static const char __pyx_k_quantity[] = "quantity"; @@ -1309,18 +1314,18 @@ static const char __pyx_k_receiver[] = "receiver"; static const char __pyx_k_reject_2[] = "_reject"; static const char __pyx_k_rejected[] = "rejected"; static const char __pyx_k_shuffled[] = "shuffled"; -static const char __pyx_k_Trade_buy[] = "Trade.buy"; static const char __pyx_k_available[] = "available"; static const char __pyx_k_inventory[] = "_inventory"; static const char __pyx_k_metaclass[] = "__metaclass__"; +static const char __pyx_k_peak_bids[] = "peak_bids"; static const char __pyx_k_trade_log[] = "_trade_log"; static const char __pyx_k_trade_pyx[] = "trade.pyx"; static const char __pyx_k_Trade_give[] = "Trade.give"; -static const char __pyx_k_Trade_sell[] = "Trade.sell"; static const char __pyx_k_Trade_take[] = "Trade.take"; static const char __pyx_k_descending[] = "descending"; static const char __pyx_k_get_offers[] = "get_offers"; static const char __pyx_k_individual[] = "individual"; +static const char __pyx_k_make_offer[] = "make_offer"; static const char __pyx_k_OrderedDict[] = "OrderedDict"; static const char __pyx_k_collections[] = "collections"; static const char __pyx_k_defaultdict[] = "defaultdict"; @@ -1332,6 +1337,7 @@ static const char __pyx_k_trade_log_2[] = "trade_log"; static const char __pyx_k_Trade___init[] = "Trade.__init__"; static const char __pyx_k_Trade_accept[] = "Trade.accept"; static const char __pyx_k_Trade_reject[] = "Trade.reject"; +static const char __pyx_k_get_bids_all[] = "get_bids_all"; static const char __pyx_k_given_offers[] = "given_offers"; static const char __pyx_k_money_amount[] = "money_amount"; static const char __pyx_k_status_round[] = "status_round"; @@ -1343,49 +1349,45 @@ static const char __pyx_k_rebuild_offer[] = "rebuild_offer"; static const char __pyx_k_trade_logging[] = "trade_logging"; static const char __pyx_k_AssertionError[] = "AssertionError"; static const char __pyx_k_NotEnoughGoods[] = "NotEnoughGoods"; +static const char __pyx_k_Trade_get_bids[] = "Trade.get_bids"; +static const char __pyx_k_Trade_get_take[] = "Trade.get_take"; +static const char __pyx_k_Trade_make_bid[] = "Trade.make_bid"; static const char __pyx_k_final_quantity[] = "final_quantity"; -static const char __pyx_k_get_buy_offers[] = "get_buy_offers"; static const char __pyx_k_get_offers_all[] = "get_offers_all"; static const char __pyx_k_offer_quantity[] = "offer_quantity"; static const char __pyx_k_receive_accept[] = "_receive_accept"; static const char __pyx_k_receive_reject[] = "_receive_reject"; static const char __pyx_k_receiver_group[] = "receiver_group"; -static const char __pyx_k_get_sell_offers[] = "get_sell_offers"; +static const char __pyx_k_Trade_peak_bids[] = "Trade.peak_bids"; static const char __pyx_k_open_offers_buy[] = "_open_offers_buy"; -static const char __pyx_k_peak_buy_offers[] = "peak_buy_offers"; static const char __pyx_k_Trade_get_offers[] = "Trade.get_offers"; +static const char __pyx_k_Trade_make_offer[] = "Trade.make_offer"; static const char __pyx_k_abce_propose_buy[] = "abce_propose_buy"; static const char __pyx_k_agent_parameters[] = "agent_parameters"; static const char __pyx_k_open_offers_sell[] = "_open_offers_sell"; -static const char __pyx_k_peak_sell_offers[] = "peak_sell_offers"; static const char __pyx_k_Trade_peak_offers[] = "Trade.peak_offers"; static const char __pyx_k_abce_propose_sell[] = "abce_propose_sell"; static const char __pyx_k_abce_receive_good[] = "abce_receive_good"; +static const char __pyx_k_Trade_get_bids_all[] = "Trade.get_bids_all"; static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; static const char __pyx_k_delete_given_offer[] = "_delete_given_offer"; -static const char __pyx_k_get_buy_offers_all[] = "get_buy_offers_all"; static const char __pyx_k_name_without_colon[] = "name_without_colon"; static const char __pyx_k_abce_notenoughgoods[] = "abce.notenoughgoods"; static const char __pyx_k_abce_receive_accept[] = "abce_receive_accept"; static const char __pyx_k_abce_receive_reject[] = "abce_receive_reject"; static const char __pyx_k_database_connection[] = "database_connection"; -static const char __pyx_k_get_sell_offers_all[] = "get_sell_offers_all"; static const char __pyx_k_Trade__advance_round[] = "Trade._advance_round"; static const char __pyx_k_Trade__offer_counter[] = "Trade._offer_counter"; -static const char __pyx_k_Trade_get_buy_offers[] = "Trade.get_buy_offers"; static const char __pyx_k_Trade_get_offers_all[] = "Trade.get_offers_all"; static const char __pyx_k_Trade__receive_accept[] = "Trade._receive_accept"; static const char __pyx_k_Trade__receive_reject[] = "Trade._receive_reject"; -static const char __pyx_k_Trade_get_sell_offers[] = "Trade.get_sell_offers"; -static const char __pyx_k_Trade_peak_buy_offers[] = "Trade.peak_buy_offers"; static const char __pyx_k_simulation_parameters[] = "simulation_parameters"; -static const char __pyx_k_Trade_peak_sell_offers[] = "Trade.peak_sell_offers"; static const char __pyx_k_offer_id_final_quantity[] = "offer_id_final_quantity"; -static const char __pyx_k_Trade_get_buy_offers_all[] = "Trade.get_buy_offers_all"; static const char __pyx_k_log_receive_accept_agent[] = "_log_receive_accept_agent"; static const char __pyx_k_log_receive_accept_group[] = "_log_receive_accept_group"; static const char __pyx_k_Trade__delete_given_offer[] = "Trade._delete_given_offer"; -static const char __pyx_k_Trade_get_sell_offers_all[] = "Trade.get_sell_offers_all"; +static const char __pyx_k_Trade_get_bids_locals_lambda[] = "Trade.get_bids.."; +static const char __pyx_k_Trade_peak_bids_locals_lambda[] = "Trade.peak_bids.."; static const char __pyx_k_Trade_get_offers_locals_lambda[] = "Trade.get_offers.."; static const char __pyx_k_reject_polled_but_not_accepted[] = "_reject_polled_but_not_accepted_offers"; static const char __pyx_k_sender_s_receiver_group_s_good[] = "<{sender: %s, receiver_group: %s, good: %s, quantity: %f, price: %f,\n sell: %r, status: %s, final_quantity: % f, id: %i,\n made: %i, status_round: %i }>"; @@ -1396,10 +1398,6 @@ static const char __pyx_k_Trade__log_receive_accept_group[] = "Trade._log_receiv static const char __pyx_k_Trade_peak_offers_locals_lambda[] = "Trade.peak_offers.."; static const char __pyx_k_s_price_quantity_30f_is_smaller[] = "%s (price * quantity) %.30f is smaller than 0 - epsilon (%.30f)"; static const char __pyx_k_Trade__reject_polled_but_not_acc[] = "Trade._reject_polled_but_not_accepted_offers"; -static const char __pyx_k_Trade_get_buy_offers_locals_lamb[] = "Trade.get_buy_offers.."; -static const char __pyx_k_Trade_get_sell_offers_locals_lam[] = "Trade.get_sell_offers.."; -static const char __pyx_k_Trade_peak_buy_offers_locals_lam[] = "Trade.peak_buy_offers.."; -static const char __pyx_k_Trade_peak_sell_offers_locals_la[] = "Trade.peak_sell_offers.."; static const char __pyx_k_accepted_more_than_offered_s_100[] = "accepted more than offered %s: %.100f >= %.100f"; static const char __pyx_k_money_quantity_offer_price_30f_i[] = "money = quantity * offer.price %.30f is smaller than 0 - epsilon (%.30f)"; static const char __pyx_k_price_30f_is_smaller_than_0_epsi[] = "price %.30f is smaller than 0 - epsilon (%.30f)"; @@ -1420,25 +1418,21 @@ static PyObject *__pyx_n_s_Trade__receive_reject; static PyObject *__pyx_n_s_Trade__reject; static PyObject *__pyx_n_s_Trade__reject_polled_but_not_acc; static PyObject *__pyx_n_s_Trade_accept; -static PyObject *__pyx_n_s_Trade_buy; -static PyObject *__pyx_n_s_Trade_get_buy_offers; -static PyObject *__pyx_n_s_Trade_get_buy_offers_all; -static PyObject *__pyx_n_s_Trade_get_buy_offers_locals_lamb; +static PyObject *__pyx_n_s_Trade_get_bids; +static PyObject *__pyx_n_s_Trade_get_bids_all; +static PyObject *__pyx_n_s_Trade_get_bids_locals_lambda; static PyObject *__pyx_n_s_Trade_get_offers; static PyObject *__pyx_n_s_Trade_get_offers_all; static PyObject *__pyx_n_s_Trade_get_offers_locals_lambda; -static PyObject *__pyx_n_s_Trade_get_sell_offers; -static PyObject *__pyx_n_s_Trade_get_sell_offers_all; -static PyObject *__pyx_n_s_Trade_get_sell_offers_locals_lam; +static PyObject *__pyx_n_s_Trade_get_take; static PyObject *__pyx_n_s_Trade_give; -static PyObject *__pyx_n_s_Trade_peak_buy_offers; -static PyObject *__pyx_n_s_Trade_peak_buy_offers_locals_lam; +static PyObject *__pyx_n_s_Trade_make_bid; +static PyObject *__pyx_n_s_Trade_make_offer; +static PyObject *__pyx_n_s_Trade_peak_bids; +static PyObject *__pyx_n_s_Trade_peak_bids_locals_lambda; static PyObject *__pyx_n_s_Trade_peak_offers; static PyObject *__pyx_n_s_Trade_peak_offers_locals_lambda; -static PyObject *__pyx_n_s_Trade_peak_sell_offers; -static PyObject *__pyx_n_s_Trade_peak_sell_offers_locals_la; static PyObject *__pyx_n_s_Trade_reject; -static PyObject *__pyx_n_s_Trade_sell; static PyObject *__pyx_n_s_Trade_take; static PyObject *__pyx_n_s_abce_notenoughgoods; static PyObject *__pyx_n_s_abce_propose_buy; @@ -1451,8 +1445,8 @@ static PyObject *__pyx_n_s_accepted; static PyObject *__pyx_kp_s_accepted_more_than_offered_s_100; static PyObject *__pyx_n_s_advance_round; static PyObject *__pyx_n_s_agent_parameters; +static PyObject *__pyx_n_s_args; static PyObject *__pyx_n_s_available; -static PyObject *__pyx_n_s_buy; static PyObject *__pyx_n_s_cline_in_traceback; static PyObject *__pyx_n_s_collections; static PyObject *__pyx_n_s_commit; @@ -1464,13 +1458,12 @@ static PyObject *__pyx_n_s_descending; static PyObject *__pyx_n_s_doc; static PyObject *__pyx_n_s_epsilon; static PyObject *__pyx_n_s_final_quantity; -static PyObject *__pyx_n_s_get_buy_offers; -static PyObject *__pyx_n_s_get_buy_offers_all; +static PyObject *__pyx_n_s_get_bids; +static PyObject *__pyx_n_s_get_bids_all; static PyObject *__pyx_n_s_get_epsilon; static PyObject *__pyx_n_s_get_offers; static PyObject *__pyx_n_s_get_offers_all; -static PyObject *__pyx_n_s_get_sell_offers; -static PyObject *__pyx_n_s_get_sell_offers_all; +static PyObject *__pyx_n_s_get_take; static PyObject *__pyx_n_s_give; static PyObject *__pyx_n_s_given_offers; static PyObject *__pyx_n_s_good; @@ -1484,10 +1477,13 @@ static PyObject *__pyx_n_s_init; static PyObject *__pyx_n_s_inventory; static PyObject *__pyx_n_s_key; static PyObject *__pyx_n_s_keys; +static PyObject *__pyx_n_s_kwargs; static PyObject *__pyx_n_s_log_receive_accept_agent; static PyObject *__pyx_n_s_log_receive_accept_group; static PyObject *__pyx_n_s_made; static PyObject *__pyx_n_s_main; +static PyObject *__pyx_n_s_make_bid; +static PyObject *__pyx_n_s_make_offer; static PyObject *__pyx_n_s_metaclass; static PyObject *__pyx_n_s_module; static PyObject *__pyx_n_s_money; @@ -1505,9 +1501,8 @@ static PyObject *__pyx_n_s_offer_id_final_quantity; static PyObject *__pyx_n_s_offer_quantity; static PyObject *__pyx_n_s_open_offers_buy; static PyObject *__pyx_n_s_open_offers_sell; -static PyObject *__pyx_n_s_peak_buy_offers; +static PyObject *__pyx_n_s_peak_bids; static PyObject *__pyx_n_s_peak_offers; -static PyObject *__pyx_n_s_peak_sell_offers; static PyObject *__pyx_n_s_polled_offers; static PyObject *__pyx_n_s_pop; static PyObject *__pyx_n_s_prepare; @@ -1583,41 +1578,37 @@ static PyObject *__pyx_pf_5trade_2rebuild_offer(CYTHON_UNUSED PyObject *__pyx_se static PyObject *__pyx_pf_5trade_5Trade___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_id, PyObject *__pyx_v_agent_parameters, PyObject *__pyx_v_simulation_parameters); /* proto */ static PyObject *__pyx_pf_5trade_5Trade_2_offer_counter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5trade_5Trade_4_advance_round(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_time); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers_all(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_descending, PyObject *__pyx_v_sorted); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers_all(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_descending, PyObject *__pyx_v_sorted); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_10get_offers_all(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_descending, PyObject *__pyx_v_sorted); /* proto */ +static PyObject *__pyx_pf_5trade_5Trade_6get_bids_all(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_descending, PyObject *__pyx_v_sorted); /* proto */ +static PyObject *__pyx_pf_5trade_5Trade_8get_offers_all(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_descending, PyObject *__pyx_v_sorted); /* proto */ static PyObject *__pyx_lambda_funcdef_lambda(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objects); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_12get_buy_offers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_good, PyObject *__pyx_v_sorted, PyObject *__pyx_v_descending, PyObject *__pyx_v_shuffled); /* proto */ +static PyObject *__pyx_pf_5trade_5Trade_10get_bids(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_good, PyObject *__pyx_v_sorted, PyObject *__pyx_v_descending, PyObject *__pyx_v_shuffled); /* proto */ static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objects); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_14get_sell_offers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_good, PyObject *__pyx_v_sorted, PyObject *__pyx_v_descending, PyObject *__pyx_v_shuffled); /* proto */ +static PyObject *__pyx_pf_5trade_5Trade_12get_offers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_good, PyObject *__pyx_v_sorted, PyObject *__pyx_v_descending, PyObject *__pyx_v_shuffled); /* proto */ static PyObject *__pyx_lambda_funcdef_lambda2(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objects); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_16get_offers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_good, PyObject *__pyx_v_sorted, PyObject *__pyx_v_descending, PyObject *__pyx_v_shuffled); /* proto */ +static PyObject *__pyx_pf_5trade_5Trade_14peak_bids(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_good, PyObject *__pyx_v_sorted, PyObject *__pyx_v_descending, PyObject *__pyx_v_shuffled); /* proto */ static PyObject *__pyx_lambda_funcdef_lambda3(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objects); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_18peak_buy_offers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_good, PyObject *__pyx_v_sorted, PyObject *__pyx_v_descending, PyObject *__pyx_v_shuffled); /* proto */ -static PyObject *__pyx_lambda_funcdef_lambda4(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objects); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_20peak_sell_offers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_good, PyObject *__pyx_v_sorted, PyObject *__pyx_v_descending, PyObject *__pyx_v_shuffled); /* proto */ -static PyObject *__pyx_lambda_funcdef_lambda5(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objects); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_22peak_offers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_good, PyObject *__pyx_v_sorted, PyObject *__pyx_v_descending, PyObject *__pyx_v_shuffled); /* proto */ +static PyObject *__pyx_pf_5trade_5Trade_16peak_offers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_good, PyObject *__pyx_v_sorted, PyObject *__pyx_v_descending, PyObject *__pyx_v_shuffled); /* proto */ static PyObject *__pyx_pf_5trade_4__defaults__(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_receiver, PyObject *__pyx_v_good, double __pyx_v_quantity, double __pyx_v_price, PyObject *__pyx_v_currency, double __pyx_v_epsilon); /* proto */ +static PyObject *__pyx_pf_5trade_5Trade_18make_offer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_receiver, PyObject *__pyx_v_good, double __pyx_v_quantity, double __pyx_v_price, PyObject *__pyx_v_currency, double __pyx_v_epsilon); /* proto */ static PyObject *__pyx_pf_5trade_6__defaults__(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_receiver, PyObject *__pyx_v_good, double __pyx_v_quantity, double __pyx_v_price, PyObject *__pyx_v_currency, double __pyx_v_epsilon); /* proto */ +static PyObject *__pyx_pf_5trade_5Trade_20make_bid(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_receiver, PyObject *__pyx_v_good, double __pyx_v_quantity, double __pyx_v_price, PyObject *__pyx_v_currency, double __pyx_v_epsilon); /* proto */ static PyObject *__pyx_pf_5trade_8__defaults__(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, struct __pyx_obj_5trade_Offer *__pyx_v_offer, double __pyx_v_quantity, double __pyx_v_epsilon); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_30_reject_polled_but_not_accepted_offers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_32_reject(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_34reject(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED struct __pyx_obj_5trade_Offer *__pyx_v_offer); /* proto */ +static PyObject *__pyx_pf_5trade_5Trade_22accept(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, struct __pyx_obj_5trade_Offer *__pyx_v_offer, double __pyx_v_quantity, double __pyx_v_epsilon); /* proto */ +static PyObject *__pyx_pf_5trade_5Trade_24_reject_polled_but_not_accepted_offers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_5trade_5Trade_26_reject(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer); /* proto */ +static PyObject *__pyx_pf_5trade_5Trade_28reject(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED struct __pyx_obj_5trade_Offer *__pyx_v_offer); /* proto */ +static PyObject *__pyx_pf_5trade_5Trade_30_log_receive_accept_group(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer); /* proto */ +static PyObject *__pyx_pf_5trade_5Trade_32_log_receive_accept_agent(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer); /* proto */ +static PyObject *__pyx_pf_5trade_5Trade_34_receive_accept(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer_id_final_quantity); /* proto */ static PyObject *__pyx_pf_5trade_5Trade_36_log_receive_accept_group(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer); /* proto */ static PyObject *__pyx_pf_5trade_5Trade_38_log_receive_accept_agent(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_40_receive_accept(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer_id_final_quantity); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_42_log_receive_accept_group(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_44_log_receive_accept_agent(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_46_receive_reject(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer_id); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_48_delete_given_offer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer_id); /* proto */ +static PyObject *__pyx_pf_5trade_5Trade_40_receive_reject(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer_id); /* proto */ +static PyObject *__pyx_pf_5trade_5Trade_42_delete_given_offer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer_id); /* proto */ static PyObject *__pyx_pf_5trade_10__defaults__(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_receiver, PyObject *__pyx_v_good, double __pyx_v_quantity, double __pyx_v_epsilon); /* proto */ +static PyObject *__pyx_pf_5trade_5Trade_44give(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_receiver, PyObject *__pyx_v_good, double __pyx_v_quantity, double __pyx_v_epsilon); /* proto */ static PyObject *__pyx_pf_5trade_12__defaults__(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ -static PyObject *__pyx_pf_5trade_5Trade_52take(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_receiver, PyObject *__pyx_v_good, double __pyx_v_quantity, double __pyx_v_epsilon); /* proto */ +static PyObject *__pyx_pf_5trade_5Trade_46take(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_receiver, PyObject *__pyx_v_good, double __pyx_v_quantity, double __pyx_v_epsilon); /* proto */ +static PyObject *__pyx_pf_5trade_5Trade_48get_take(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */ static PyObject *__pyx_tp_new_5trade_Offer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_int_0; static PyObject *__pyx_int_1; @@ -1643,25 +1634,20 @@ static PyObject *__pyx_tuple__26; static PyObject *__pyx_tuple__28; static PyObject *__pyx_tuple__29; static PyObject *__pyx_tuple__31; -static PyObject *__pyx_tuple__32; -static PyObject *__pyx_tuple__34; +static PyObject *__pyx_tuple__33; static PyObject *__pyx_tuple__35; static PyObject *__pyx_tuple__37; -static PyObject *__pyx_tuple__38; -static PyObject *__pyx_tuple__40; -static PyObject *__pyx_tuple__42; -static PyObject *__pyx_tuple__44; -static PyObject *__pyx_tuple__46; -static PyObject *__pyx_tuple__48; -static PyObject *__pyx_tuple__50; -static PyObject *__pyx_tuple__52; -static PyObject *__pyx_tuple__54; -static PyObject *__pyx_tuple__56; -static PyObject *__pyx_tuple__58; -static PyObject *__pyx_tuple__60; -static PyObject *__pyx_tuple__62; -static PyObject *__pyx_tuple__64; -static PyObject *__pyx_tuple__66; +static PyObject *__pyx_tuple__39; +static PyObject *__pyx_tuple__41; +static PyObject *__pyx_tuple__43; +static PyObject *__pyx_tuple__45; +static PyObject *__pyx_tuple__47; +static PyObject *__pyx_tuple__49; +static PyObject *__pyx_tuple__51; +static PyObject *__pyx_tuple__53; +static PyObject *__pyx_tuple__55; +static PyObject *__pyx_tuple__57; +static PyObject *__pyx_tuple__59; static PyObject *__pyx_codeobj__2; static PyObject *__pyx_codeobj__4; static PyObject *__pyx_codeobj__6; @@ -1674,23 +1660,21 @@ static PyObject *__pyx_codeobj__21; static PyObject *__pyx_codeobj__24; static PyObject *__pyx_codeobj__27; static PyObject *__pyx_codeobj__30; -static PyObject *__pyx_codeobj__33; +static PyObject *__pyx_codeobj__32; +static PyObject *__pyx_codeobj__34; static PyObject *__pyx_codeobj__36; -static PyObject *__pyx_codeobj__39; -static PyObject *__pyx_codeobj__41; -static PyObject *__pyx_codeobj__43; -static PyObject *__pyx_codeobj__45; -static PyObject *__pyx_codeobj__47; -static PyObject *__pyx_codeobj__49; -static PyObject *__pyx_codeobj__51; -static PyObject *__pyx_codeobj__53; -static PyObject *__pyx_codeobj__55; -static PyObject *__pyx_codeobj__57; -static PyObject *__pyx_codeobj__59; -static PyObject *__pyx_codeobj__61; -static PyObject *__pyx_codeobj__63; -static PyObject *__pyx_codeobj__65; -static PyObject *__pyx_codeobj__67; +static PyObject *__pyx_codeobj__38; +static PyObject *__pyx_codeobj__40; +static PyObject *__pyx_codeobj__42; +static PyObject *__pyx_codeobj__44; +static PyObject *__pyx_codeobj__46; +static PyObject *__pyx_codeobj__48; +static PyObject *__pyx_codeobj__50; +static PyObject *__pyx_codeobj__52; +static PyObject *__pyx_codeobj__54; +static PyObject *__pyx_codeobj__56; +static PyObject *__pyx_codeobj__58; +static PyObject *__pyx_codeobj__60; /* Late includes */ /* "trade.pyx":46 @@ -4174,7 +4158,7 @@ static PyObject *__pyx_pf_5trade_5Trade_4_advance_round(CYTHON_UNUSED PyObject * * self.database_connection.put(["trade_log", self._trade_log, self.time]) * self._trade_log = defaultdict(int) # <<<<<<<<<<<<<< * - * def get_buy_offers_all(self, descending=False, sorted=True): + * def get_bids_all(self, descending=True, sorted=True): */ __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_defaultdict); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); @@ -4252,25 +4236,26 @@ static PyObject *__pyx_pf_5trade_5Trade_4_advance_round(CYTHON_UNUSED PyObject * /* "trade.pyx":252 * self._trade_log = defaultdict(int) * - * 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} + * def get_bids_all(self, descending=True, sorted=True): # <<<<<<<<<<<<<< + * """ returns all bids in a dictionary, with goods as key. The in each + * goods-category the goods are ordered by price. The order can be reversed */ /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_7get_buy_offers_all(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5trade_5Trade_7get_buy_offers_all = {"get_buy_offers_all", (PyCFunction)__pyx_pw_5trade_5Trade_7get_buy_offers_all, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_5trade_5Trade_7get_buy_offers_all(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5trade_5Trade_7get_bids_all(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5trade_5Trade_6get_bids_all[] = " returns all bids in a dictionary, with goods as key. The in each\n goods-category the goods are ordered by price. The order can be reversed\n by setting descending=False\n\n *Bids that are not accepted in the same subround are\n automatically rejected.* However you can also manually reject.\n\n Args:\n\n descending(=True):\n False for descending True for ascending by price\n\n sorted(=True):\n Whether offers are sorted by price. Faster if False.\n\n Returns:\n\n a dictionary with good types as keys and list of :class:`abce.trade.Offer`\n as values\n\n Example::\n\n oo = get_bids_all()\n for good_category in oo:\n print('The most expensive offer for good in category' + good_category\n + ' is ' + good_category[0])\n for bid in oo[good_category]:\n if bid.price < 0.5:\n self.accept(bid)\n\n for bid in oo.beer:\n print(bid.price, bid.sender_group, bid.sender_id)\n "; +static PyMethodDef __pyx_mdef_5trade_5Trade_7get_bids_all = {"get_bids_all", (PyCFunction)__pyx_pw_5trade_5Trade_7get_bids_all, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_6get_bids_all}; +static PyObject *__pyx_pw_5trade_5Trade_7get_bids_all(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_descending = 0; PyObject *__pyx_v_sorted = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_buy_offers_all (wrapper)", 0); + __Pyx_RefNannySetupContext("get_bids_all (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_descending,&__pyx_n_s_sorted,0}; PyObject* values[3] = {0,0,0}; - values[1] = ((PyObject *)((PyObject *)Py_False)); + values[1] = ((PyObject *)((PyObject *)Py_True)); values[2] = ((PyObject *)((PyObject *)Py_True)); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; @@ -4304,7 +4289,7 @@ static PyObject *__pyx_pw_5trade_5Trade_7get_buy_offers_all(PyObject *__pyx_self } } 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, 252, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_bids_all") < 0)) __PYX_ERR(0, 252, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -4323,20 +4308,20 @@ static PyObject *__pyx_pw_5trade_5Trade_7get_buy_offers_all(PyObject *__pyx_self } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("get_buy_offers_all", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 252, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("get_bids_all", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 252, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("trade.Trade.get_buy_offers_all", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("trade.Trade.get_bids_all", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5trade_5Trade_6get_buy_offers_all(__pyx_self, __pyx_v_self, __pyx_v_descending, __pyx_v_sorted); + __pyx_r = __pyx_pf_5trade_5Trade_6get_bids_all(__pyx_self, __pyx_v_self, __pyx_v_descending, __pyx_v_sorted); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers_all(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_descending, PyObject *__pyx_v_sorted) { +static PyObject *__pyx_pf_5trade_5Trade_6get_bids_all(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_descending, PyObject *__pyx_v_sorted) { PyObject *__pyx_v_goods = NULL; PyObject *__pyx_7genexpr__pyx_v_good = NULL; PyObject *__pyx_r = NULL; @@ -4349,18 +4334,18 @@ static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers_all(CYTHON_UNUSED PyObje PyObject *__pyx_t_6 = NULL; int __pyx_t_7; PyObject *__pyx_t_8 = NULL; - __Pyx_RefNannySetupContext("get_buy_offers_all", 0); + __Pyx_RefNannySetupContext("get_bids_all", 0); - /* "trade.pyx":253 - * - * def get_buy_offers_all(self, descending=False, sorted=True): + /* "trade.pyx":286 + * print(bid.price, bid.sender_group, bid.sender_id) + * """ * 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(__pyx_v_self, __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 253, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __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, 253, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_keys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; @@ -4374,42 +4359,42 @@ static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers_all(CYTHON_UNUSED PyObje } } if (__pyx_t_2) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 253, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __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, 253, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __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, 253, __pyx_L1_error) + __pyx_t_3 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __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":254 - * def get_buy_offers_all(self, descending=False, sorted=True): + /* "trade.pyx":287 + * """ * goods = list(self._open_offers_buy.keys()) * return {good: self.get_offers(good, descending, sorted) for good in goods} # <<<<<<<<<<<<<< * - * def get_sell_offers_all(self, descending=False, sorted=True): + * def get_offers_all(self, descending=False, sorted=True): */ __Pyx_XDECREF(__pyx_r); { /* enter inner scope */ - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 254, __pyx_L5_error) + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 287, __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, 254, __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, 287, __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, 254, __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, 287, __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(__pyx_v_self, __pyx_n_s_get_offers); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 254, __pyx_L5_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_get_offers); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 287, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; @@ -4426,7 +4411,7 @@ static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers_all(CYTHON_UNUSED PyObje #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, 254, __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, 287, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_2); } else @@ -4434,13 +4419,13 @@ static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers_all(CYTHON_UNUSED PyObje #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, 254, __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, 287, __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, 254, __pyx_L5_error) + __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 287, __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; @@ -4454,12 +4439,12 @@ static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers_all(CYTHON_UNUSED PyObje __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, 254, __pyx_L5_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 287, __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, 254, __pyx_L5_error) + if (unlikely(PyDict_SetItem(__pyx_t_3, (PyObject*)__pyx_7genexpr__pyx_v_good, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 287, __pyx_L5_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -4477,9 +4462,9 @@ static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers_all(CYTHON_UNUSED PyObje /* "trade.pyx":252 * self._trade_log = defaultdict(int) * - * 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} + * def get_bids_all(self, descending=True, sorted=True): # <<<<<<<<<<<<<< + * """ returns all bids in a dictionary, with goods as key. The in each + * goods-category the goods are ordered by price. The order can be reversed */ /* function exit code */ @@ -4490,7 +4475,7 @@ static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers_all(CYTHON_UNUSED PyObje __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("trade.Trade.get_buy_offers_all", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("trade.Trade.get_bids_all", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_goods); @@ -4500,24 +4485,25 @@ static PyObject *__pyx_pf_5trade_5Trade_6get_buy_offers_all(CYTHON_UNUSED PyObje return __pyx_r; } -/* "trade.pyx":256 +/* "trade.pyx":289 * return {good: self.get_offers(good, descending, sorted) for good in goods} * - * 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} + * def get_offers_all(self, descending=False, sorted=True): # <<<<<<<<<<<<<< + * """ returns all offers in a dictionary, with goods as key. The in each + * goods-category the goods are ordered by price. The order can be reversed */ /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_9get_sell_offers_all(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5trade_5Trade_9get_sell_offers_all = {"get_sell_offers_all", (PyCFunction)__pyx_pw_5trade_5Trade_9get_sell_offers_all, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_5trade_5Trade_9get_sell_offers_all(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5trade_5Trade_9get_offers_all(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5trade_5Trade_8get_offers_all[] = " returns all offers in a dictionary, with goods as key. The in each\n goods-category the goods are ordered by price. The order can be reversed\n by setting descending=True\n\n *Offers that are not accepted in the same subround are\n automatically rejected.* However you can also manually reject.\n\n Args:\n\n descending(=False):\n is a bool. False for descending True for ascending by price\n\n sorted(default=True):\n Whether offers are sorted by price. Faster if False.\n\n Returns:\n\n a dictionary with good types as keys and list of :class:`abce.trade.Offer`\n as values\n\n Example::\n\n oo = get_offers_all(descending=False)\n for good_category in oo:\n print('The cheapest good of category' + good_category\n + ' is ' + good_category[0])\n for offer in oo[good_category]:\n if offer.price < 0.5:\n self.accept(offer)\n\n for offer in oo.beer:\n print(offer.price, offer.sender_group, offer.sender_id)\n "; +static PyMethodDef __pyx_mdef_5trade_5Trade_9get_offers_all = {"get_offers_all", (PyCFunction)__pyx_pw_5trade_5Trade_9get_offers_all, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_8get_offers_all}; +static PyObject *__pyx_pw_5trade_5Trade_9get_offers_all(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_descending = 0; PyObject *__pyx_v_sorted = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_sell_offers_all (wrapper)", 0); + __Pyx_RefNannySetupContext("get_offers_all (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_descending,&__pyx_n_s_sorted,0}; PyObject* values[3] = {0,0,0}; @@ -4555,7 +4541,7 @@ static PyObject *__pyx_pw_5trade_5Trade_9get_sell_offers_all(PyObject *__pyx_sel } } 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, 256, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_offers_all") < 0)) __PYX_ERR(0, 289, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -4574,20 +4560,20 @@ static PyObject *__pyx_pw_5trade_5Trade_9get_sell_offers_all(PyObject *__pyx_sel } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("get_sell_offers_all", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 256, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("get_offers_all", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 289, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("trade.Trade.get_sell_offers_all", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("trade.Trade.get_offers_all", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5trade_5Trade_8get_sell_offers_all(__pyx_self, __pyx_v_self, __pyx_v_descending, __pyx_v_sorted); + __pyx_r = __pyx_pf_5trade_5Trade_8get_offers_all(__pyx_self, __pyx_v_self, __pyx_v_descending, __pyx_v_sorted); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers_all(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_descending, PyObject *__pyx_v_sorted) { +static PyObject *__pyx_pf_5trade_5Trade_8get_offers_all(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_descending, PyObject *__pyx_v_sorted) { PyObject *__pyx_v_goods = NULL; PyObject *__pyx_8genexpr1__pyx_v_good = NULL; PyObject *__pyx_r = NULL; @@ -4600,18 +4586,18 @@ static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers_all(CYTHON_UNUSED PyObj PyObject *__pyx_t_6 = NULL; int __pyx_t_7; PyObject *__pyx_t_8 = NULL; - __Pyx_RefNannySetupContext("get_sell_offers_all", 0); + __Pyx_RefNannySetupContext("get_offers_all", 0); - /* "trade.pyx":257 - * - * def get_sell_offers_all(self, descending=False, sorted=True): + /* "trade.pyx":323 + * print(offer.price, offer.sender_group, offer.sender_id) + * """ * 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(__pyx_v_self, __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 323, __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, 257, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_keys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; @@ -4625,42 +4611,42 @@ static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers_all(CYTHON_UNUSED PyObj } } if (__pyx_t_2) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 257, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 323, __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, 257, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 323, __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, 257, __pyx_L1_error) + __pyx_t_3 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 323, __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":258 - * def get_sell_offers_all(self, descending=False, sorted=True): + /* "trade.pyx":324 + * """ * goods = list(self._open_offers_sell.keys()) * return {good: self.get_offers(good, descending, sorted) for good in goods} # <<<<<<<<<<<<<< * - * def get_offers_all(self, descending=False, sorted=True): + * def get_bids(self, good, sorted=True, descending=True, shuffled=True): */ __Pyx_XDECREF(__pyx_r); { /* enter inner scope */ - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 258, __pyx_L5_error) + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 324, __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, 258, __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, 324, __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, 258, __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, 324, __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(__pyx_v_self, __pyx_n_s_get_offers); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 258, __pyx_L5_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_get_offers); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 324, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; @@ -4677,7 +4663,7 @@ static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers_all(CYTHON_UNUSED PyObj #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, 258, __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, 324, __pyx_L5_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_2); } else @@ -4685,13 +4671,13 @@ static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers_all(CYTHON_UNUSED PyObj #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, 258, __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, 324, __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, 258, __pyx_L5_error) + __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 324, __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; @@ -4705,12 +4691,12 @@ static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers_all(CYTHON_UNUSED PyObj __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, 258, __pyx_L5_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 324, __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, 258, __pyx_L5_error) + if (unlikely(PyDict_SetItem(__pyx_t_3, (PyObject*)__pyx_8genexpr1__pyx_v_good, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 324, __pyx_L5_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -4725,12 +4711,12 @@ static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers_all(CYTHON_UNUSED PyObj __pyx_t_3 = 0; goto __pyx_L0; - /* "trade.pyx":256 + /* "trade.pyx":289 * return {good: self.get_offers(good, descending, sorted) for good in goods} * - * 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} + * def get_offers_all(self, descending=False, sorted=True): # <<<<<<<<<<<<<< + * """ returns all offers in a dictionary, with goods as key. The in each + * goods-category the goods are ordered by price. The order can be reversed */ /* function exit code */ @@ -4741,7 +4727,7 @@ static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers_all(CYTHON_UNUSED PyObj __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("trade.Trade.get_sell_offers_all", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("trade.Trade.get_offers_all", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_goods); @@ -4751,34 +4737,41 @@ static PyObject *__pyx_pf_5trade_5Trade_8get_sell_offers_all(CYTHON_UNUSED PyObj return __pyx_r; } -/* "trade.pyx":260 +/* "trade.pyx":326 * return {good: self.get_offers(good, descending, sorted) for good in goods} * - * def get_offers_all(self, descending=False, sorted=True): # <<<<<<<<<<<<<< - * """ returns all offers in a dictionary, with goods as key. The in each - * goods-category the goods are ordered by price. The order can be reversed + * def get_bids(self, good, sorted=True, descending=True, shuffled=True): # <<<<<<<<<<<<<< + * """ returns all bids of the 'good' ordered by price. + * */ /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_11get_offers_all(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_5trade_5Trade_10get_offers_all[] = " returns all offers in a dictionary, with goods as key. The in each\n goods-category the goods are ordered by price. The order can be reversed\n by setting descending=True\n\n *Offers that are not accepted in the same subround (def block) are\n automatically rejected.* However you can also manually reject.\n\n Args:\n\n descending(optional):\n is a bool. False for descending True for ascending by price\n\n sorted(default=True):\n Whether offers are sorted by price. Faster if False.\n\n Returns:\n\n a dictionary with good types as keys and list of :class:`abce.trade.Offer`\n as values\n\n Example::\n\n oo = get_offers_all(descending=False)\n for good_category in oo:\n print('The cheapest good of category' + good_category\n + ' is ' + good_category[0])\n for offer in oo[good_category]:\n if offer.price < 0.5:\n self.accept(offer)\n\n for offer in oo.beer:\n print(offer.price, offer.sender_group, offer.sender_id)\n "; -static PyMethodDef __pyx_mdef_5trade_5Trade_11get_offers_all = {"get_offers_all", (PyCFunction)__pyx_pw_5trade_5Trade_11get_offers_all, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_10get_offers_all}; -static PyObject *__pyx_pw_5trade_5Trade_11get_offers_all(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5trade_5Trade_11get_bids(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5trade_5Trade_10get_bids[] = " returns all bids of the 'good' ordered by price.\n\n *Bids that are not accepted in the same subround are\n automatically rejected.* However you can also manually reject.\n\n peek_bids can be used to look at the bids without them being\n rejected automatically\n\n Args:\n good:\n the good which should be retrieved\n\n sorted(=True):\n Whether bids are sorted by price. Faster if False.\n\n descending(=True):\n False for descending True for ascending by price\n\n shuffled(=True):\n whether the order of messages is randomized or correlated with\n the ID of the agent. Setting this to False speeds up the\n simulation considerably, but introduces a bias.\n\n Returns:\n A list of :class:`abce.trade.Offer` ordered by price.\n\n Example::\n\n bids = get_bids('books')\n for bid in bids:\n if offer.price < 50:\n self.accept(bid)\n elif bid.price < 100:\n self.accept(bid, 1)\n else:\n self.reject(bid) # optional\n "; +static PyMethodDef __pyx_mdef_5trade_5Trade_11get_bids = {"get_bids", (PyCFunction)__pyx_pw_5trade_5Trade_11get_bids, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_10get_bids}; +static PyObject *__pyx_pw_5trade_5Trade_11get_bids(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; - PyObject *__pyx_v_descending = 0; + PyObject *__pyx_v_good = 0; PyObject *__pyx_v_sorted = 0; + PyObject *__pyx_v_descending = 0; + PyObject *__pyx_v_shuffled = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_offers_all (wrapper)", 0); + __Pyx_RefNannySetupContext("get_bids (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_descending,&__pyx_n_s_sorted,0}; - PyObject* values[3] = {0,0,0}; - values[1] = ((PyObject *)((PyObject *)Py_False)); + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_good,&__pyx_n_s_sorted,&__pyx_n_s_descending,&__pyx_n_s_shuffled,0}; + PyObject* values[5] = {0,0,0,0,0}; values[2] = ((PyObject *)((PyObject *)Py_True)); + values[3] = ((PyObject *)((PyObject *)Py_True)); + values[4] = ((PyObject *)((PyObject *)Py_True)); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + CYTHON_FALLTHROUGH; + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + CYTHON_FALLTHROUGH; case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); @@ -4795,9 +4788,9 @@ static PyObject *__pyx_pw_5trade_5Trade_11get_offers_all(PyObject *__pyx_self, P else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: - if (kw_args > 0) { - PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_descending); - if (value) { values[1] = value; kw_args--; } + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_good)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("get_bids", 0, 2, 5, 1); __PYX_ERR(0, 326, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: @@ -4805,214 +4798,373 @@ static PyObject *__pyx_pw_5trade_5Trade_11get_offers_all(PyObject *__pyx_self, P PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sorted); if (value) { values[2] = value; kw_args--; } } + CYTHON_FALLTHROUGH; + case 3: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_descending); + if (value) { values[3] = value; kw_args--; } + } + CYTHON_FALLTHROUGH; + case 4: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_shuffled); + if (value) { values[4] = value; kw_args--; } + } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_offers_all") < 0)) __PYX_ERR(0, 260, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_bids") < 0)) __PYX_ERR(0, 326, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + CYTHON_FALLTHROUGH; + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + CYTHON_FALLTHROUGH; case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_self = values[0]; - __pyx_v_descending = values[1]; + __pyx_v_good = values[1]; __pyx_v_sorted = values[2]; + __pyx_v_descending = values[3]; + __pyx_v_shuffled = values[4]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("get_offers_all", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 260, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("get_bids", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 326, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("trade.Trade.get_offers_all", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("trade.Trade.get_bids", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5trade_5Trade_10get_offers_all(__pyx_self, __pyx_v_self, __pyx_v_descending, __pyx_v_sorted); + __pyx_r = __pyx_pf_5trade_5Trade_10get_bids(__pyx_self, __pyx_v_self, __pyx_v_good, __pyx_v_sorted, __pyx_v_descending, __pyx_v_shuffled); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_5trade_5Trade_10get_offers_all(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_descending, PyObject *__pyx_v_sorted) { - PyObject *__pyx_v_goods = NULL; - PyObject *__pyx_8genexpr2__pyx_v_good = NULL; +/* "trade.pyx":370 + * random.shuffle(ret) + * if sorted: + * ret.sort(key=lambda objects: objects.price, reverse=descending) # <<<<<<<<<<<<<< + * return ret + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_5trade_5Trade_8get_bids_lambda(PyObject *__pyx_self, PyObject *__pyx_v_objects); /*proto*/ +static PyMethodDef __pyx_mdef_5trade_5Trade_8get_bids_lambda = {"lambda", (PyCFunction)__pyx_pw_5trade_5Trade_8get_bids_lambda, METH_O, 0}; +static PyObject *__pyx_pw_5trade_5Trade_8get_bids_lambda(PyObject *__pyx_self, PyObject *__pyx_v_objects) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("lambda (wrapper)", 0); + __pyx_r = __pyx_lambda_funcdef_lambda(__pyx_self, ((PyObject *)__pyx_v_objects)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_lambda_funcdef_lambda(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objects) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + 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, 370, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("trade.Trade.get_bids.lambda", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "trade.pyx":326 + * return {good: self.get_offers(good, descending, sorted) for good in goods} + * + * def get_bids(self, good, sorted=True, descending=True, shuffled=True): # <<<<<<<<<<<<<< + * """ returns all bids of the 'good' ordered by price. + * + */ + +static PyObject *__pyx_pf_5trade_5Trade_10get_bids(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_good, PyObject *__pyx_v_sorted, PyObject *__pyx_v_descending, PyObject *__pyx_v_shuffled) { + PyObject *__pyx_v_ret = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; - Py_ssize_t __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - int __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - __Pyx_RefNannySetupContext("get_offers_all", 0); + PyObject *__pyx_t_5 = NULL; + int __pyx_t_6; + __Pyx_RefNannySetupContext("get_bids", 0); - /* "trade.pyx":294 - * print(offer.price, offer.sender_group, offer.sender_id) + /* "trade.pyx":364 + * self.reject(bid) # optional * """ - * goods = list(self._open_offers_sell.keys()) + list(self._open_offers_buy.keys()) # <<<<<<<<<<<<<< - * return {good: self.get_offers(good, descending, sorted) for good in goods} - * + * 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(__pyx_v_self, __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 294, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 364, __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, 294, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 364, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_2)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_2); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 364, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); + __Pyx_DECREF_SET(__pyx_t_2, function); } } - if (__pyx_t_2) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (__pyx_t_3) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 364, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 364, __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, 294, __pyx_L1_error) + __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, 364, __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":365 + * """ + * 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(__pyx_v_self, __pyx_n_s_polled_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __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, 365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 294, __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, 294, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_good); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = NULL; - 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_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_1)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); + __Pyx_DECREF_SET(__pyx_t_3, function); } } - if (__pyx_t_2) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (!__pyx_t_1) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 365, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_2); } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error) + #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, 365, __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_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, 365, __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, 365, __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, 365, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } } - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 294, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_v_goods = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":295 - * """ - * goods = list(self._open_offers_sell.keys()) + list(self._open_offers_buy.keys()) - * return {good: self.get_offers(good, descending, sorted) for good in goods} # <<<<<<<<<<<<<< - * - * def get_buy_offers(self, good, sorted=True, descending=False, shuffled=True): + /* "trade.pyx":366 + * 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_XDECREF(__pyx_r); - { /* enter inner scope */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 295, __pyx_L5_error) - __Pyx_GOTREF(__pyx_t_1); - __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_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 295, __pyx_L5_error) - #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 295, __pyx_L5_error) - __Pyx_GOTREF(__pyx_t_3); - #endif - __Pyx_XDECREF_SET(__pyx_8genexpr2__pyx_v_good, __pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_get_offers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 295, __pyx_L5_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = NULL; - __pyx_t_7 = 0; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - __pyx_t_7 = 1; - } - } - #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_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 295, __pyx_L5_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 366, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (unlikely(PyObject_DelItem(__pyx_t_2, __pyx_v_good) < 0)) __PYX_ERR(0, 366, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "trade.pyx":367 + * 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, 367, __pyx_L1_error) + if (__pyx_t_6) { + + /* "trade.pyx":368 + * 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, 368, __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, 368, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + } + } + if (!__pyx_t_3) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __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_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, 368, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); } else #endif #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_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 295, __pyx_L5_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_3); + 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, 368, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 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, 295, __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; - } - __Pyx_INCREF(__pyx_8genexpr2__pyx_v_good); - __Pyx_GIVEREF(__pyx_8genexpr2__pyx_v_good); - PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_8genexpr2__pyx_v_good); - __Pyx_INCREF(__pyx_v_descending); - __Pyx_GIVEREF(__pyx_v_descending); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_descending); - __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_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 295, __pyx_L5_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 368, __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, 368, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(PyDict_SetItem(__pyx_t_1, (PyObject*)__pyx_8genexpr2__pyx_v_good, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 295, __pyx_L5_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "trade.pyx":367 + * self._polled_offers.update(self._open_offers_buy[good]) + * del self._open_offers_buy[good] + * if shuffled: # <<<<<<<<<<<<<< + * random.shuffle(ret) + * if sorted: + */ + } + + /* "trade.pyx":369 + * 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, 369, __pyx_L1_error) + if (__pyx_t_6) { + + /* "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, 370, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 370, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_8get_bids_lambda, 0, __pyx_n_s_Trade_get_bids_locals_lambda, NULL, __pyx_n_s_trade, __pyx_d, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 370, __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, 370, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_good); __pyx_8genexpr2__pyx_v_good = 0; - goto __pyx_L8_exit_scope; - __pyx_L5_error:; - __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_good); __pyx_8genexpr2__pyx_v_good = 0; - goto __pyx_L1_error; - __pyx_L8_exit_scope:; - } /* exit inner scope */ - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; + if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_reverse, __pyx_v_descending) < 0) __PYX_ERR(0, 370, __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, 370, __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":369 + * if shuffled: + * random.shuffle(ret) + * if sorted: # <<<<<<<<<<<<<< + * ret.sort(key=lambda objects: objects.price, reverse=descending) + * return ret + */ + } + + /* "trade.pyx":371 + * if sorted: + * ret.sort(key=lambda objects: objects.price, reverse=descending) + * return ret # <<<<<<<<<<<<<< + * + * def get_offers(self, good, sorted=True, descending=False, shuffled=True): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_ret); + __pyx_r = __pyx_v_ret; goto __pyx_L0; - /* "trade.pyx":260 + /* "trade.pyx":326 * return {good: self.get_offers(good, descending, sorted) for good in goods} * - * def get_offers_all(self, descending=False, sorted=True): # <<<<<<<<<<<<<< - * """ returns all offers in a dictionary, with goods as key. The in each - * goods-category the goods are ordered by price. The order can be reversed + * def get_bids(self, good, sorted=True, descending=True, shuffled=True): # <<<<<<<<<<<<<< + * """ returns all bids of the 'good' ordered by price. + * */ /* function exit code */ @@ -5021,30 +5173,29 @@ static PyObject *__pyx_pf_5trade_5Trade_10get_offers_all(CYTHON_UNUSED PyObject __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("trade.Trade.get_offers_all", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("trade.Trade.get_bids", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_goods); - __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_good); + __Pyx_XDECREF(__pyx_v_ret); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "trade.pyx":297 - * return {good: self.get_offers(good, descending, sorted) for good in goods} +/* "trade.pyx":373 + * return ret + * + * def get_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< + * """ returns all offers of the 'good' ordered by price. * - * 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]) */ /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_13get_buy_offers(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5trade_5Trade_13get_buy_offers = {"get_buy_offers", (PyCFunction)__pyx_pw_5trade_5Trade_13get_buy_offers, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_5trade_5Trade_13get_buy_offers(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5trade_5Trade_13get_offers(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5trade_5Trade_12get_offers[] = " returns all offers of the 'good' ordered by price.\n\n *Offers that are not accepted in the same subround are\n automatically rejected.* However you can also manually reject.\n\n peek_offers can be used to look at the offers without them being\n rejected automatically\n\n Args:\n good:\n the good which should be retrieved\n\n sorted(=True):\n Whether offers are sorted by price. Faster if False.\n\n descending(=False):\n False for descending True for ascending by price\n\n shuffled(=True):\n whether the order of messages is randomized or correlated with\n the ID of the agent. Setting this to False speeds up the\n simulation considerably, but introduces a bias.\n\n Returns:\n A list of :class:`abce.trade.Offer` 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 PyMethodDef __pyx_mdef_5trade_5Trade_13get_offers = {"get_offers", (PyCFunction)__pyx_pw_5trade_5Trade_13get_offers, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_12get_offers}; +static PyObject *__pyx_pw_5trade_5Trade_13get_offers(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_good = 0; PyObject *__pyx_v_sorted = 0; @@ -5052,7 +5203,7 @@ static PyObject *__pyx_pw_5trade_5Trade_13get_buy_offers(PyObject *__pyx_self, P PyObject *__pyx_v_shuffled = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_buy_offers (wrapper)", 0); + __Pyx_RefNannySetupContext("get_offers (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_good,&__pyx_n_s_sorted,&__pyx_n_s_descending,&__pyx_n_s_shuffled,0}; PyObject* values[5] = {0,0,0,0,0}; @@ -5085,7 +5236,7 @@ static PyObject *__pyx_pw_5trade_5Trade_13get_buy_offers(PyObject *__pyx_self, P case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_good)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("get_buy_offers", 0, 2, 5, 1); __PYX_ERR(0, 297, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("get_offers", 0, 2, 5, 1); __PYX_ERR(0, 373, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: @@ -5107,7 +5258,7 @@ static PyObject *__pyx_pw_5trade_5Trade_13get_buy_offers(PyObject *__pyx_self, P } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_buy_offers") < 0)) __PYX_ERR(0, 297, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_offers") < 0)) __PYX_ERR(0, 373, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -5131,20 +5282,20 @@ static PyObject *__pyx_pw_5trade_5Trade_13get_buy_offers(PyObject *__pyx_self, P } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("get_buy_offers", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 297, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("get_offers", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 373, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("trade.Trade.get_buy_offers", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("trade.Trade.get_offers", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5trade_5Trade_12get_buy_offers(__pyx_self, __pyx_v_self, __pyx_v_good, __pyx_v_sorted, __pyx_v_descending, __pyx_v_shuffled); + __pyx_r = __pyx_pf_5trade_5Trade_12get_offers(__pyx_self, __pyx_v_self, __pyx_v_good, __pyx_v_sorted, __pyx_v_descending, __pyx_v_shuffled); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "trade.pyx":304 +/* "trade.pyx":417 * random.shuffle(ret) * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) # <<<<<<<<<<<<<< @@ -5153,26 +5304,26 @@ static PyObject *__pyx_pw_5trade_5Trade_13get_buy_offers(PyObject *__pyx_self, P */ /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_14get_buy_offers_lambda(PyObject *__pyx_self, PyObject *__pyx_v_objects); /*proto*/ -static PyMethodDef __pyx_mdef_5trade_5Trade_14get_buy_offers_lambda = {"lambda", (PyCFunction)__pyx_pw_5trade_5Trade_14get_buy_offers_lambda, METH_O, 0}; -static PyObject *__pyx_pw_5trade_5Trade_14get_buy_offers_lambda(PyObject *__pyx_self, PyObject *__pyx_v_objects) { +static PyObject *__pyx_pw_5trade_5Trade_10get_offers_lambda1(PyObject *__pyx_self, PyObject *__pyx_v_objects); /*proto*/ +static PyMethodDef __pyx_mdef_5trade_5Trade_10get_offers_lambda1 = {"lambda1", (PyCFunction)__pyx_pw_5trade_5Trade_10get_offers_lambda1, METH_O, 0}; +static PyObject *__pyx_pw_5trade_5Trade_10get_offers_lambda1(PyObject *__pyx_self, PyObject *__pyx_v_objects) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("lambda (wrapper)", 0); - __pyx_r = __pyx_lambda_funcdef_lambda(__pyx_self, ((PyObject *)__pyx_v_objects)); + __Pyx_RefNannySetupContext("lambda1 (wrapper)", 0); + __pyx_r = __pyx_lambda_funcdef_lambda1(__pyx_self, ((PyObject *)__pyx_v_objects)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_lambda_funcdef_lambda(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objects) { +static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objects) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("lambda", 0); + __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, 304, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_objects, __pyx_n_s_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -5181,7 +5332,7 @@ static PyObject *__pyx_lambda_funcdef_lambda(CYTHON_UNUSED PyObject *__pyx_self, /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("trade.Trade.get_buy_offers.lambda", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("trade.Trade.get_offers.lambda1", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -5189,15 +5340,15 @@ static PyObject *__pyx_lambda_funcdef_lambda(CYTHON_UNUSED PyObject *__pyx_self, return __pyx_r; } -/* "trade.pyx":297 - * return {good: self.get_offers(good, descending, sorted) for good in goods} +/* "trade.pyx":373 + * return ret + * + * def get_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< + * """ returns all offers of the 'good' ordered by price. * - * 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]) */ -static PyObject *__pyx_pf_5trade_5Trade_12get_buy_offers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_good, PyObject *__pyx_v_sorted, PyObject *__pyx_v_descending, PyObject *__pyx_v_shuffled) { +static PyObject *__pyx_pf_5trade_5Trade_12get_offers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_good, PyObject *__pyx_v_sorted, PyObject *__pyx_v_descending, PyObject *__pyx_v_shuffled) { PyObject *__pyx_v_ret = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -5207,21 +5358,21 @@ static PyObject *__pyx_pf_5trade_5Trade_12get_buy_offers(CYTHON_UNUSED PyObject PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; - __Pyx_RefNannySetupContext("get_buy_offers", 0); + __Pyx_RefNannySetupContext("get_offers", 0); - /* "trade.pyx":298 - * - * 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] + /* "trade.pyx":411 + * self.reject(offer) # optional + * """ + * 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(__pyx_v_self, __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 411, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 298, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 411, __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, 298, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 411, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; @@ -5235,34 +5386,34 @@ static PyObject *__pyx_pf_5trade_5Trade_12get_buy_offers(CYTHON_UNUSED PyObject } } if (__pyx_t_3) { - __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_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 411, __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, 298, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 411, __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, 298, __pyx_L1_error) + __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 411, __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":299 - * 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] + /* "trade.pyx":412 + * """ + * 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(__pyx_v_self, __pyx_n_s_polled_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 299, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_polled_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 412, __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, 299, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_update); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 412, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 299, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 412, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_good); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 299, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_good); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 412, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; @@ -5276,14 +5427,14 @@ static PyObject *__pyx_pf_5trade_5Trade_12get_buy_offers(CYTHON_UNUSED PyObject } } if (!__pyx_t_1) { - __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_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 412, __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, 299, __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, 412, __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; @@ -5292,20 +5443,20 @@ static PyObject *__pyx_pf_5trade_5Trade_12get_buy_offers(CYTHON_UNUSED PyObject #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, 299, __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, 412, __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, 299, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 412, __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, 299, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 412, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } @@ -5313,38 +5464,38 @@ static PyObject *__pyx_pf_5trade_5Trade_12get_buy_offers(CYTHON_UNUSED PyObject __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":300 - * ret = list(self._open_offers_buy[good].values()) - * self._polled_offers.update(self._open_offers_buy[good]) - * del self._open_offers_buy[good] # <<<<<<<<<<<<<< + /* "trade.pyx":413 + * 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(__pyx_v_self, __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 300, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (unlikely(PyObject_DelItem(__pyx_t_2, __pyx_v_good) < 0)) __PYX_ERR(0, 300, __pyx_L1_error) + if (unlikely(PyObject_DelItem(__pyx_t_2, __pyx_v_good) < 0)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":301 - * self._polled_offers.update(self._open_offers_buy[good]) - * del self._open_offers_buy[good] + /* "trade.pyx":414 + * 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, 301, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_shuffled); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 414, __pyx_L1_error) if (__pyx_t_6) { - /* "trade.pyx":302 - * del self._open_offers_buy[good] + /* "trade.pyx":415 + * 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, 302, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 415, __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, 302, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; @@ -5358,13 +5509,13 @@ static PyObject *__pyx_pf_5trade_5Trade_12get_buy_offers(CYTHON_UNUSED PyObject } } if (!__pyx_t_3) { - __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_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_ret); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 415, __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, 302, __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, 415, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_2); } else @@ -5372,19 +5523,19 @@ static PyObject *__pyx_pf_5trade_5Trade_12get_buy_offers(CYTHON_UNUSED PyObject #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, 302, __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, 415, __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, 302, __pyx_L1_error) + __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 415, __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, 302, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } @@ -5392,48 +5543,48 @@ static PyObject *__pyx_pf_5trade_5Trade_12get_buy_offers(CYTHON_UNUSED PyObject __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":301 - * self._polled_offers.update(self._open_offers_buy[good]) - * del self._open_offers_buy[good] + /* "trade.pyx":414 + * self._polled_offers.update(self._open_offers_sell[good]) + * del self._open_offers_sell[good] * if shuffled: # <<<<<<<<<<<<<< * random.shuffle(ret) * if sorted: */ } - /* "trade.pyx":303 + /* "trade.pyx":416 * 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, 303, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_sorted); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 416, __pyx_L1_error) if (__pyx_t_6) { - /* "trade.pyx":304 + /* "trade.pyx":417 * 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, 304, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ret, __pyx_n_s_sort); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 304, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 417, __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_Trade_get_buy_offers_locals_lamb, NULL, __pyx_n_s_trade, __pyx_d, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 304, __pyx_L1_error) + __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_10get_offers_lambda1, 0, __pyx_n_s_Trade_get_offers_locals_lambda, NULL, __pyx_n_s_trade, __pyx_d, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 417, __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, 304, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_key, __pyx_t_4) < 0) __PYX_ERR(0, 417, __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, 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) + if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_reverse, __pyx_v_descending) < 0) __PYX_ERR(0, 417, __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, 417, __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":303 + /* "trade.pyx":416 * if shuffled: * random.shuffle(ret) * if sorted: # <<<<<<<<<<<<<< @@ -5442,24 +5593,24 @@ static PyObject *__pyx_pf_5trade_5Trade_12get_buy_offers(CYTHON_UNUSED PyObject */ } - /* "trade.pyx":305 + /* "trade.pyx":418 * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) * return ret # <<<<<<<<<<<<<< * - * def get_sell_offers(self, good, sorted=True, descending=False, shuffled=True): + * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_ret); __pyx_r = __pyx_v_ret; goto __pyx_L0; - /* "trade.pyx":297 - * return {good: self.get_offers(good, descending, sorted) for good in goods} + /* "trade.pyx":373 + * return ret + * + * def get_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< + * """ returns all offers of the 'good' ordered by price. * - * 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]) */ /* function exit code */ @@ -5469,7 +5620,7 @@ static PyObject *__pyx_pf_5trade_5Trade_12get_buy_offers(CYTHON_UNUSED PyObject __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("trade.Trade.get_buy_offers", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("trade.Trade.get_offers", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_ret); @@ -5478,18 +5629,19 @@ static PyObject *__pyx_pf_5trade_5Trade_12get_buy_offers(CYTHON_UNUSED PyObject return __pyx_r; } -/* "trade.pyx":307 - * return ret +/* "trade.pyx":421 * - * 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]) + * + * def peak_bids(self, good, sorted=True, descending=True, shuffled=True): # <<<<<<<<<<<<<< + * """ returns a peak on all bids for the 'good' ordered by price. + * Peaked bids can not be accepted or rejected and they do not */ /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_15get_sell_offers(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5trade_5Trade_15get_sell_offers = {"get_sell_offers", (PyCFunction)__pyx_pw_5trade_5Trade_15get_sell_offers, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_5trade_5Trade_15get_sell_offers(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5trade_5Trade_15peak_bids(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5trade_5Trade_14peak_bids[] = " returns a peak on all bids for the 'good' ordered by price.\n Peaked bids 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 sorted(=True):\n whether the bids are sorted, switch off for speed\n\n descending(=True):\n sort order\n\n shuffled(=True):\n randomizes equal prized bids, switch off for speed\n\n Returns:\n A list of bids ordered by price\n\n Example::\n\n bids = get_bids('books')\n for bid in bids:\n if bid.price < 50:\n self.accept(bid)\n elif bid.price < 100:\n self.accept(bid, 1)\n else:\n self.reject(bid) # optional\n "; +static PyMethodDef __pyx_mdef_5trade_5Trade_15peak_bids = {"peak_bids", (PyCFunction)__pyx_pw_5trade_5Trade_15peak_bids, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_14peak_bids}; +static PyObject *__pyx_pw_5trade_5Trade_15peak_bids(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_good = 0; PyObject *__pyx_v_sorted = 0; @@ -5497,12 +5649,12 @@ static PyObject *__pyx_pw_5trade_5Trade_15get_sell_offers(PyObject *__pyx_self, PyObject *__pyx_v_shuffled = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_sell_offers (wrapper)", 0); + __Pyx_RefNannySetupContext("peak_bids (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_good,&__pyx_n_s_sorted,&__pyx_n_s_descending,&__pyx_n_s_shuffled,0}; PyObject* values[5] = {0,0,0,0,0}; values[2] = ((PyObject *)((PyObject *)Py_True)); - values[3] = ((PyObject *)((PyObject *)Py_False)); + values[3] = ((PyObject *)((PyObject *)Py_True)); values[4] = ((PyObject *)((PyObject *)Py_True)); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; @@ -5530,7 +5682,7 @@ static PyObject *__pyx_pw_5trade_5Trade_15get_sell_offers(PyObject *__pyx_self, case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_good)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("get_sell_offers", 0, 2, 5, 1); __PYX_ERR(0, 307, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("peak_bids", 0, 2, 5, 1); __PYX_ERR(0, 421, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: @@ -5552,7 +5704,7 @@ static PyObject *__pyx_pw_5trade_5Trade_15get_sell_offers(PyObject *__pyx_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, 307, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "peak_bids") < 0)) __PYX_ERR(0, 421, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -5576,20 +5728,20 @@ static PyObject *__pyx_pw_5trade_5Trade_15get_sell_offers(PyObject *__pyx_self, } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("get_sell_offers", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 307, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("peak_bids", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 421, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("trade.Trade.get_sell_offers", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("trade.Trade.peak_bids", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5trade_5Trade_14get_sell_offers(__pyx_self, __pyx_v_self, __pyx_v_good, __pyx_v_sorted, __pyx_v_descending, __pyx_v_shuffled); + __pyx_r = __pyx_pf_5trade_5Trade_14peak_bids(__pyx_self, __pyx_v_self, __pyx_v_good, __pyx_v_sorted, __pyx_v_descending, __pyx_v_shuffled); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "trade.pyx":314 +/* "trade.pyx":461 * random.shuffle(ret) * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) # <<<<<<<<<<<<<< @@ -5598,26 +5750,26 @@ static PyObject *__pyx_pw_5trade_5Trade_15get_sell_offers(PyObject *__pyx_self, */ /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_15get_sell_offers_lambda1(PyObject *__pyx_self, PyObject *__pyx_v_objects); /*proto*/ -static PyMethodDef __pyx_mdef_5trade_5Trade_15get_sell_offers_lambda1 = {"lambda1", (PyCFunction)__pyx_pw_5trade_5Trade_15get_sell_offers_lambda1, METH_O, 0}; -static PyObject *__pyx_pw_5trade_5Trade_15get_sell_offers_lambda1(PyObject *__pyx_self, PyObject *__pyx_v_objects) { +static PyObject *__pyx_pw_5trade_5Trade_9peak_bids_lambda2(PyObject *__pyx_self, PyObject *__pyx_v_objects); /*proto*/ +static PyMethodDef __pyx_mdef_5trade_5Trade_9peak_bids_lambda2 = {"lambda2", (PyCFunction)__pyx_pw_5trade_5Trade_9peak_bids_lambda2, METH_O, 0}; +static PyObject *__pyx_pw_5trade_5Trade_9peak_bids_lambda2(PyObject *__pyx_self, PyObject *__pyx_v_objects) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("lambda1 (wrapper)", 0); - __pyx_r = __pyx_lambda_funcdef_lambda1(__pyx_self, ((PyObject *)__pyx_v_objects)); + __Pyx_RefNannySetupContext("lambda2 (wrapper)", 0); + __pyx_r = __pyx_lambda_funcdef_lambda2(__pyx_self, ((PyObject *)__pyx_v_objects)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objects) { +static PyObject *__pyx_lambda_funcdef_lambda2(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objects) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("lambda1", 0); + __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, 314, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_objects, __pyx_n_s_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -5626,7 +5778,7 @@ static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("trade.Trade.get_sell_offers.lambda1", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("trade.Trade.peak_bids.lambda2", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -5634,1293 +5786,15 @@ static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self return __pyx_r; } -/* "trade.pyx":307 - * return ret - * - * 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]) - */ - -static PyObject *__pyx_pf_5trade_5Trade_14get_sell_offers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_good, PyObject *__pyx_v_sorted, PyObject *__pyx_v_descending, PyObject *__pyx_v_shuffled) { - PyObject *__pyx_v_ret = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - int __pyx_t_6; - __Pyx_RefNannySetupContext("get_sell_offers", 0); - - /* "trade.pyx":308 - * - * 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(__pyx_v_self, __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 308, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 308, __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, 308, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __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, 308, __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, 308, __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":309 - * 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(__pyx_v_self, __pyx_n_s_polled_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __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, 309, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 309, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_good); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 309, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_1)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_1); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (!__pyx_t_1) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 309, __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, 309, __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_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, 309, __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, 309, __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, 309, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "trade.pyx":310 - * 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(__pyx_v_self, __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 310, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (unlikely(PyObject_DelItem(__pyx_t_2, __pyx_v_good) < 0)) __PYX_ERR(0, 310, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "trade.pyx":311 - * 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, 311, __pyx_L1_error) - if (__pyx_t_6) { - - /* "trade.pyx":312 - * 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, 312, __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, 312, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - } - } - if (!__pyx_t_3) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_ret); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 312, __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, 312, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - #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, 312, __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, 312, __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, 312, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "trade.pyx":311 - * self._polled_offers.update(self._open_offers_sell[good]) - * del self._open_offers_sell[good] - * if shuffled: # <<<<<<<<<<<<<< - * random.shuffle(ret) - * if sorted: - */ - } - - /* "trade.pyx":313 - * 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, 313, __pyx_L1_error) - if (__pyx_t_6) { - - /* "trade.pyx":314 - * 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, 314, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 314, __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_Trade_get_sell_offers_locals_lam, NULL, __pyx_n_s_trade, __pyx_d, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 314, __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, 314, __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, 314, __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, 314, __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":313 - * if shuffled: - * random.shuffle(ret) - * if sorted: # <<<<<<<<<<<<<< - * ret.sort(key=lambda objects: objects.price, reverse=descending) - * return ret - */ - } - - /* "trade.pyx":315 - * if sorted: - * ret.sort(key=lambda objects: objects.price, reverse=descending) - * return ret # <<<<<<<<<<<<<< - * - * def get_offers(self, good, sorted=True, descending=False, shuffled=True): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_ret); - __pyx_r = __pyx_v_ret; - goto __pyx_L0; - - /* "trade.pyx":307 - * return ret - * - * 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]) - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("trade.Trade.get_sell_offers", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_ret); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "trade.pyx":317 - * return ret - * - * def get_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< - * """ returns all offers of the 'good' ordered by price. - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_17get_offers(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_5trade_5Trade_16get_offers[] = " returns all offers of the 'good' ordered by price.\n\n *Offers that are not accepted in the same subround (def block) are\n automatically rejected.* However you can also manually reject.\n\n peek_offers can be used to look at the offers without them being\n rejected automatically\n\n Args:\n good:\n the good which should be retrieved\n\n sorted(bool, default=True):\n Whether offers are sorted by price. Faster if False.\n\n descending(bool, default=False):\n False for descending True for ascending by price\n\n shuffled(bool, default=True):\n whether the order of messages is randomized or correlated with\n the ID of the agent. Setting this to False speeds up the\n simulation considerably, but introduces a bias.\n\n Returns:\n A list of :class:`abce.trade.Offer` 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 PyMethodDef __pyx_mdef_5trade_5Trade_17get_offers = {"get_offers", (PyCFunction)__pyx_pw_5trade_5Trade_17get_offers, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_16get_offers}; -static PyObject *__pyx_pw_5trade_5Trade_17get_offers(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_self = 0; - PyObject *__pyx_v_good = 0; - PyObject *__pyx_v_sorted = 0; - PyObject *__pyx_v_descending = 0; - PyObject *__pyx_v_shuffled = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_offers (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_good,&__pyx_n_s_sorted,&__pyx_n_s_descending,&__pyx_n_s_shuffled,0}; - PyObject* values[5] = {0,0,0,0,0}; - values[2] = ((PyObject *)((PyObject *)Py_True)); - values[3] = ((PyObject *)((PyObject *)Py_False)); - values[4] = ((PyObject *)((PyObject *)Py_True)); - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - CYTHON_FALLTHROUGH; - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - CYTHON_FALLTHROUGH; - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_good)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("get_offers", 0, 2, 5, 1); __PYX_ERR(0, 317, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (kw_args > 0) { - PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sorted); - if (value) { values[2] = value; kw_args--; } - } - CYTHON_FALLTHROUGH; - case 3: - if (kw_args > 0) { - PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_descending); - if (value) { values[3] = value; kw_args--; } - } - CYTHON_FALLTHROUGH; - case 4: - if (kw_args > 0) { - PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_shuffled); - if (value) { values[4] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_offers") < 0)) __PYX_ERR(0, 317, __pyx_L3_error) - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - CYTHON_FALLTHROUGH; - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - CYTHON_FALLTHROUGH; - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_self = values[0]; - __pyx_v_good = values[1]; - __pyx_v_sorted = values[2]; - __pyx_v_descending = values[3]; - __pyx_v_shuffled = values[4]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("get_offers", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 317, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("trade.Trade.get_offers", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5trade_5Trade_16get_offers(__pyx_self, __pyx_v_self, __pyx_v_good, __pyx_v_sorted, __pyx_v_descending, __pyx_v_shuffled); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "trade.pyx":360 - * random.shuffle(ret) - * if sorted: - * ret.sort(key=lambda objects: objects.price, reverse=descending) # <<<<<<<<<<<<<< - * return ret - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_10get_offers_lambda2(PyObject *__pyx_self, PyObject *__pyx_v_objects); /*proto*/ -static PyMethodDef __pyx_mdef_5trade_5Trade_10get_offers_lambda2 = {"lambda2", (PyCFunction)__pyx_pw_5trade_5Trade_10get_offers_lambda2, METH_O, 0}; -static PyObject *__pyx_pw_5trade_5Trade_10get_offers_lambda2(PyObject *__pyx_self, PyObject *__pyx_v_objects) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("lambda2 (wrapper)", 0); - __pyx_r = __pyx_lambda_funcdef_lambda2(__pyx_self, ((PyObject *)__pyx_v_objects)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_lambda_funcdef_lambda2(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objects) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - 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, 360, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("trade.Trade.get_offers.lambda2", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "trade.pyx":317 - * return ret - * - * def get_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< - * """ returns all offers of the 'good' ordered by price. - * - */ - -static PyObject *__pyx_pf_5trade_5Trade_16get_offers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_good, PyObject *__pyx_v_sorted, PyObject *__pyx_v_descending, PyObject *__pyx_v_shuffled) { - PyObject *__pyx_v_ret = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - int __pyx_t_6; - __Pyx_RefNannySetupContext("get_offers", 0); - - /* "trade.pyx":355 - * 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(__pyx_v_self, __pyx_n_s_get_buy_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 355, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 355, __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 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 355, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_descending, Py_False) < 0) __PYX_ERR(0, 355, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_sorted, Py_False) < 0) __PYX_ERR(0, 355, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_shuffled, Py_False) < 0) __PYX_ERR(0, 355, __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, 355, __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":356 - * """ - * 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(__pyx_v_self, __pyx_n_s_get_sell_offers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 356, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 356, __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 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 356, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_descending, Py_False) < 0) __PYX_ERR(0, 356, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_sorted, Py_False) < 0) __PYX_ERR(0, 356, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_shuffled, Py_False) < 0) __PYX_ERR(0, 356, __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, 356, __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":355 - * 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, 355, __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":357 - * 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, 357, __pyx_L1_error) - if (__pyx_t_6) { - - /* "trade.pyx":358 - * 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, 358, __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, 358, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(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); - } - } - if (!__pyx_t_5) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_ret); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 358, __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, 358, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #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, 358, __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, 358, __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, 358, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "trade.pyx":357 - * 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: - */ - } - - /* "trade.pyx":359 - * 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, 359, __pyx_L1_error) - if (__pyx_t_6) { - - /* "trade.pyx":360 - * 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, 360, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 360, __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_Trade_get_offers_locals_lambda, NULL, __pyx_n_s_trade, __pyx_d, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 360, __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, 360, __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, 360, __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, 360, __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":359 - * if shuffled: - * random.shuffle(ret) - * if sorted: # <<<<<<<<<<<<<< - * ret.sort(key=lambda objects: objects.price, reverse=descending) - * return ret - */ - } - - /* "trade.pyx":361 - * if sorted: - * ret.sort(key=lambda objects: objects.price, reverse=descending) - * return ret # <<<<<<<<<<<<<< - * - * def peak_buy_offers(self, good, sorted=True, descending=False, shuffled=True): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_ret); - __pyx_r = __pyx_v_ret; - goto __pyx_L0; - - /* "trade.pyx":317 - * return ret - * - * def get_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< - * """ returns all offers of the 'good' ordered by price. - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("trade.Trade.get_offers", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_ret); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "trade.pyx":363 - * return ret - * - * def peak_buy_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< - * ret = [] - * for offer in self._open_offers_buy[good].values(): - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_19peak_buy_offers(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5trade_5Trade_19peak_buy_offers = {"peak_buy_offers", (PyCFunction)__pyx_pw_5trade_5Trade_19peak_buy_offers, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_5trade_5Trade_19peak_buy_offers(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_self = 0; - PyObject *__pyx_v_good = 0; - PyObject *__pyx_v_sorted = 0; - PyObject *__pyx_v_descending = 0; - PyObject *__pyx_v_shuffled = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("peak_buy_offers (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_good,&__pyx_n_s_sorted,&__pyx_n_s_descending,&__pyx_n_s_shuffled,0}; - PyObject* values[5] = {0,0,0,0,0}; - values[2] = ((PyObject *)((PyObject *)Py_True)); - values[3] = ((PyObject *)((PyObject *)Py_False)); - values[4] = ((PyObject *)((PyObject *)Py_True)); - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - CYTHON_FALLTHROUGH; - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - CYTHON_FALLTHROUGH; - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_good)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("peak_buy_offers", 0, 2, 5, 1); __PYX_ERR(0, 363, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (kw_args > 0) { - PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sorted); - if (value) { values[2] = value; kw_args--; } - } - CYTHON_FALLTHROUGH; - case 3: - if (kw_args > 0) { - PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_descending); - if (value) { values[3] = value; kw_args--; } - } - CYTHON_FALLTHROUGH; - case 4: - if (kw_args > 0) { - PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_shuffled); - if (value) { values[4] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "peak_buy_offers") < 0)) __PYX_ERR(0, 363, __pyx_L3_error) - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - CYTHON_FALLTHROUGH; - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - CYTHON_FALLTHROUGH; - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_self = values[0]; - __pyx_v_good = values[1]; - __pyx_v_sorted = values[2]; - __pyx_v_descending = values[3]; - __pyx_v_shuffled = values[4]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("peak_buy_offers", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 363, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("trade.Trade.peak_buy_offers", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5trade_5Trade_18peak_buy_offers(__pyx_self, __pyx_v_self, __pyx_v_good, __pyx_v_sorted, __pyx_v_descending, __pyx_v_shuffled); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "trade.pyx":370 - * random.shuffle(ret) - * if sorted: - * ret.sort(key=lambda objects: objects.price, reverse=descending) # <<<<<<<<<<<<<< - * return ret - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_15peak_buy_offers_lambda3(PyObject *__pyx_self, PyObject *__pyx_v_objects); /*proto*/ -static PyMethodDef __pyx_mdef_5trade_5Trade_15peak_buy_offers_lambda3 = {"lambda3", (PyCFunction)__pyx_pw_5trade_5Trade_15peak_buy_offers_lambda3, METH_O, 0}; -static PyObject *__pyx_pw_5trade_5Trade_15peak_buy_offers_lambda3(PyObject *__pyx_self, PyObject *__pyx_v_objects) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("lambda3 (wrapper)", 0); - __pyx_r = __pyx_lambda_funcdef_lambda3(__pyx_self, ((PyObject *)__pyx_v_objects)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_lambda_funcdef_lambda3(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objects) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - 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, 370, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("trade.Trade.peak_buy_offers.lambda3", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "trade.pyx":363 - * return ret - * - * def peak_buy_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< - * ret = [] - * for offer in self._open_offers_buy[good].values(): - */ - -static PyObject *__pyx_pf_5trade_5Trade_18peak_buy_offers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_good, PyObject *__pyx_v_sorted, PyObject *__pyx_v_descending, PyObject *__pyx_v_shuffled) { - PyObject *__pyx_v_ret = NULL; - PyObject *__pyx_v_offer = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - Py_ssize_t __pyx_t_4; - PyObject *(*__pyx_t_5)(PyObject *); - int __pyx_t_6; - int __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - __Pyx_RefNannySetupContext("peak_buy_offers", 0); - - /* "trade.pyx":364 - * - * 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, 364, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_ret = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; - - /* "trade.pyx":365 - * 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(__pyx_v_self, __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 365, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_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, 365, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (__pyx_t_3) { - __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, 365, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { - __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, 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, 365, __pyx_L1_error) - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - for (;;) { - if (likely(!__pyx_t_5)) { - 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, 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, 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, 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, 365, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - #endif - } - } else { - __pyx_t_1 = __pyx_t_5(__pyx_t_2); - if (unlikely(!__pyx_t_1)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 365, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_1); - } - __Pyx_XDECREF_SET(__pyx_v_offer, __pyx_t_1); - __pyx_t_1 = 0; - - /* "trade.pyx":366 - * 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 == ((int)-1))) __PYX_ERR(0, 366, __pyx_L1_error) - - /* "trade.pyx":365 - * 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_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "trade.pyx":367 - * 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, 367, __pyx_L1_error) - if (__pyx_t_7) { - - /* "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, 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, 368, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_1)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_1); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (!__pyx_t_1) { - __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, 368, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - #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, 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, 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, 368, __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":367 - * for offer in self._open_offers_buy[good].values(): - * ret.append(offer) - * if shuffled: # <<<<<<<<<<<<<< - * random.shuffle(ret) - * if sorted: - */ - } - - /* "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, 369, __pyx_L1_error) - if (__pyx_t_7) { - - /* "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, 370, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyDict_NewPresized(2); 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_15peak_buy_offers_lambda3, 0, __pyx_n_s_Trade_peak_buy_offers_locals_lam, 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, 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, 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":369 - * if shuffled: - * random.shuffle(ret) - * if sorted: # <<<<<<<<<<<<<< - * ret.sort(key=lambda objects: objects.price, reverse=descending) - * return ret - */ - } - - /* "trade.pyx":371 - * if sorted: - * ret.sort(key=lambda objects: objects.price, reverse=descending) - * return ret # <<<<<<<<<<<<<< - * - * def peak_sell_offers(self, good, sorted=True, descending=False, shuffled=True): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_ret); - __pyx_r = __pyx_v_ret; - goto __pyx_L0; - - /* "trade.pyx":363 - * return ret - * - * def peak_buy_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< - * ret = [] - * for offer in self._open_offers_buy[good].values(): - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("trade.Trade.peak_buy_offers", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_ret); - __Pyx_XDECREF(__pyx_v_offer); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "trade.pyx":373 - * return ret - * - * def peak_sell_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< - * ret = [] - * for offer in self._open_offers_sell[good].values(): - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_21peak_sell_offers(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5trade_5Trade_21peak_sell_offers = {"peak_sell_offers", (PyCFunction)__pyx_pw_5trade_5Trade_21peak_sell_offers, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_5trade_5Trade_21peak_sell_offers(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_self = 0; - PyObject *__pyx_v_good = 0; - PyObject *__pyx_v_sorted = 0; - PyObject *__pyx_v_descending = 0; - PyObject *__pyx_v_shuffled = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("peak_sell_offers (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_good,&__pyx_n_s_sorted,&__pyx_n_s_descending,&__pyx_n_s_shuffled,0}; - PyObject* values[5] = {0,0,0,0,0}; - values[2] = ((PyObject *)((PyObject *)Py_True)); - values[3] = ((PyObject *)((PyObject *)Py_False)); - values[4] = ((PyObject *)((PyObject *)Py_True)); - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - CYTHON_FALLTHROUGH; - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - CYTHON_FALLTHROUGH; - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_good)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("peak_sell_offers", 0, 2, 5, 1); __PYX_ERR(0, 373, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (kw_args > 0) { - PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sorted); - if (value) { values[2] = value; kw_args--; } - } - CYTHON_FALLTHROUGH; - case 3: - if (kw_args > 0) { - PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_descending); - if (value) { values[3] = value; kw_args--; } - } - CYTHON_FALLTHROUGH; - case 4: - if (kw_args > 0) { - PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_shuffled); - if (value) { values[4] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "peak_sell_offers") < 0)) __PYX_ERR(0, 373, __pyx_L3_error) - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - CYTHON_FALLTHROUGH; - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - CYTHON_FALLTHROUGH; - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_self = values[0]; - __pyx_v_good = values[1]; - __pyx_v_sorted = values[2]; - __pyx_v_descending = values[3]; - __pyx_v_shuffled = values[4]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("peak_sell_offers", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 373, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("trade.Trade.peak_sell_offers", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5trade_5Trade_20peak_sell_offers(__pyx_self, __pyx_v_self, __pyx_v_good, __pyx_v_sorted, __pyx_v_descending, __pyx_v_shuffled); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "trade.pyx":380 - * random.shuffle(ret) - * if sorted: - * ret.sort(key=lambda objects: objects.price, reverse=descending) # <<<<<<<<<<<<<< - * return ret - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_16peak_sell_offers_lambda4(PyObject *__pyx_self, PyObject *__pyx_v_objects); /*proto*/ -static PyMethodDef __pyx_mdef_5trade_5Trade_16peak_sell_offers_lambda4 = {"lambda4", (PyCFunction)__pyx_pw_5trade_5Trade_16peak_sell_offers_lambda4, METH_O, 0}; -static PyObject *__pyx_pw_5trade_5Trade_16peak_sell_offers_lambda4(PyObject *__pyx_self, PyObject *__pyx_v_objects) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("lambda4 (wrapper)", 0); - __pyx_r = __pyx_lambda_funcdef_lambda4(__pyx_self, ((PyObject *)__pyx_v_objects)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_lambda_funcdef_lambda4(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objects) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - 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, 380, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("trade.Trade.peak_sell_offers.lambda4", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "trade.pyx":373 - * return ret +/* "trade.pyx":421 * - * def peak_sell_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< - * ret = [] - * for offer in self._open_offers_sell[good].values(): + * + * def peak_bids(self, good, sorted=True, descending=True, shuffled=True): # <<<<<<<<<<<<<< + * """ returns a peak on all bids for the 'good' ordered by price. + * Peaked bids can not be accepted or rejected and they do not */ -static PyObject *__pyx_pf_5trade_5Trade_20peak_sell_offers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_good, PyObject *__pyx_v_sorted, PyObject *__pyx_v_descending, PyObject *__pyx_v_shuffled) { +static PyObject *__pyx_pf_5trade_5Trade_14peak_bids(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_good, PyObject *__pyx_v_sorted, PyObject *__pyx_v_descending, PyObject *__pyx_v_shuffled) { PyObject *__pyx_v_ret = NULL; PyObject *__pyx_v_offer = NULL; PyObject *__pyx_r = NULL; @@ -6933,33 +5807,33 @@ static PyObject *__pyx_pf_5trade_5Trade_20peak_sell_offers(CYTHON_UNUSED PyObjec int __pyx_t_6; int __pyx_t_7; PyObject *__pyx_t_8 = NULL; - __Pyx_RefNannySetupContext("peak_sell_offers", 0); + __Pyx_RefNannySetupContext("peak_bids", 0); - /* "trade.pyx":374 - * - * def peak_sell_offers(self, good, sorted=True, descending=False, shuffled=True): + /* "trade.pyx":455 + * self.reject(bid) # optional + * """ * ret = [] # <<<<<<<<<<<<<< - * for offer in self._open_offers_sell[good].values(): + * 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, 374, __pyx_L1_error) + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_ret = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":375 - * def peak_sell_offers(self, good, sorted=True, descending=False, shuffled=True): + /* "trade.pyx":456 + * """ * ret = [] - * for offer in self._open_offers_sell[good].values(): # <<<<<<<<<<<<<< + * for offer in self._open_offers_buy[good].values(): # <<<<<<<<<<<<<< * ret.append(offer) * if shuffled: */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 375, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_open_offers_buy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 456, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 375, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 456, __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, 375, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 456, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; @@ -6973,10 +5847,10 @@ static PyObject *__pyx_pf_5trade_5Trade_20peak_sell_offers(CYTHON_UNUSED PyObjec } } if (__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 375, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 456, __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, 375, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 456, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -6984,9 +5858,9 @@ static PyObject *__pyx_pf_5trade_5Trade_20peak_sell_offers(CYTHON_UNUSED PyObjec __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, 375, __pyx_L1_error) + __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 456, __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, 375, __pyx_L1_error) + __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 456, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { @@ -6994,17 +5868,17 @@ static PyObject *__pyx_pf_5trade_5Trade_20peak_sell_offers(CYTHON_UNUSED PyObjec 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, 375, __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, 456, __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, 375, __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, 456, __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, 375, __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, 456, __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, 375, __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, 456, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } @@ -7014,7 +5888,7 @@ static PyObject *__pyx_pf_5trade_5Trade_20peak_sell_offers(CYTHON_UNUSED PyObjec PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 375, __pyx_L1_error) + else __PYX_ERR(0, 456, __pyx_L1_error) } break; } @@ -7023,45 +5897,45 @@ static PyObject *__pyx_pf_5trade_5Trade_20peak_sell_offers(CYTHON_UNUSED PyObjec __Pyx_XDECREF_SET(__pyx_v_offer, __pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":376 + /* "trade.pyx":457 * ret = [] - * for offer in self._open_offers_sell[good].values(): + * 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 == ((int)-1))) __PYX_ERR(0, 376, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_v_offer); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 457, __pyx_L1_error) - /* "trade.pyx":375 - * def peak_sell_offers(self, good, sorted=True, descending=False, shuffled=True): + /* "trade.pyx":456 + * """ * ret = [] - * for offer in self._open_offers_sell[good].values(): # <<<<<<<<<<<<<< + * for offer in self._open_offers_buy[good].values(): # <<<<<<<<<<<<<< * ret.append(offer) * if shuffled: */ } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":377 - * for offer in self._open_offers_sell[good].values(): + /* "trade.pyx":458 + * 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, 377, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_shuffled); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 458, __pyx_L1_error) if (__pyx_t_7) { - /* "trade.pyx":378 + /* "trade.pyx":459 * 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, 378, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 459, __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, 378, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 459, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; @@ -7075,13 +5949,13 @@ static PyObject *__pyx_pf_5trade_5Trade_20peak_sell_offers(CYTHON_UNUSED PyObjec } } if (!__pyx_t_1) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_ret); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 378, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_ret); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 459, __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, 378, __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, 459, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_2); } else @@ -7089,19 +5963,19 @@ static PyObject *__pyx_pf_5trade_5Trade_20peak_sell_offers(CYTHON_UNUSED PyObjec #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, 378, __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, 459, __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, 378, __pyx_L1_error) + __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 459, __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, 378, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 459, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } @@ -7109,8 +5983,8 @@ static PyObject *__pyx_pf_5trade_5Trade_20peak_sell_offers(CYTHON_UNUSED PyObjec __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":377 - * for offer in self._open_offers_sell[good].values(): + /* "trade.pyx":458 + * for offer in self._open_offers_buy[good].values(): * ret.append(offer) * if shuffled: # <<<<<<<<<<<<<< * random.shuffle(ret) @@ -7118,39 +5992,39 @@ static PyObject *__pyx_pf_5trade_5Trade_20peak_sell_offers(CYTHON_UNUSED PyObjec */ } - /* "trade.pyx":379 + /* "trade.pyx":460 * 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, 379, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_sorted); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 460, __pyx_L1_error) if (__pyx_t_7) { - /* "trade.pyx":380 + /* "trade.pyx":461 * 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, 380, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ret, __pyx_n_s_sort); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 380, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 461, __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_Trade_peak_sell_offers_locals_la, NULL, __pyx_n_s_trade, __pyx_d, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 380, __pyx_L1_error) + __pyx_t_8 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_9peak_bids_lambda2, 0, __pyx_n_s_Trade_peak_bids_locals_lambda, NULL, __pyx_n_s_trade, __pyx_d, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 461, __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, 380, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_key, __pyx_t_8) < 0) __PYX_ERR(0, 461, __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, 380, __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, 380, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reverse, __pyx_v_descending) < 0) __PYX_ERR(0, 461, __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, 461, __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":379 + /* "trade.pyx":460 * if shuffled: * random.shuffle(ret) * if sorted: # <<<<<<<<<<<<<< @@ -7159,7 +6033,7 @@ static PyObject *__pyx_pf_5trade_5Trade_20peak_sell_offers(CYTHON_UNUSED PyObjec */ } - /* "trade.pyx":381 + /* "trade.pyx":462 * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) * return ret # <<<<<<<<<<<<<< @@ -7171,12 +6045,12 @@ static PyObject *__pyx_pf_5trade_5Trade_20peak_sell_offers(CYTHON_UNUSED PyObjec __pyx_r = __pyx_v_ret; goto __pyx_L0; - /* "trade.pyx":373 - * return ret + /* "trade.pyx":421 * - * def peak_sell_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< - * ret = [] - * for offer in self._open_offers_sell[good].values(): + * + * def peak_bids(self, good, sorted=True, descending=True, shuffled=True): # <<<<<<<<<<<<<< + * """ returns a peak on all bids for the 'good' ordered by price. + * Peaked bids can not be accepted or rejected and they do not */ /* function exit code */ @@ -7185,7 +6059,7 @@ static PyObject *__pyx_pf_5trade_5Trade_20peak_sell_offers(CYTHON_UNUSED PyObjec __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("trade.Trade.peak_sell_offers", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("trade.Trade.peak_bids", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_ret); @@ -7195,7 +6069,7 @@ static PyObject *__pyx_pf_5trade_5Trade_20peak_sell_offers(CYTHON_UNUSED PyObjec return __pyx_r; } -/* "trade.pyx":383 +/* "trade.pyx":464 * return ret * * def peak_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< @@ -7204,10 +6078,10 @@ static PyObject *__pyx_pf_5trade_5Trade_20peak_sell_offers(CYTHON_UNUSED PyObjec */ /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_23peak_offers(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_5trade_5Trade_22peak_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 PyMethodDef __pyx_mdef_5trade_5Trade_23peak_offers = {"peak_offers", (PyCFunction)__pyx_pw_5trade_5Trade_23peak_offers, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_22peak_offers}; -static PyObject *__pyx_pw_5trade_5Trade_23peak_offers(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5trade_5Trade_17peak_offers(PyObject *__pyx_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\n sorted(=True):\n whether the bids are sorted, switch off for speed\n\n descending(=False):\n sort order\n\n shuffled(=True):\n randomizes equal prized bids, switch off for speed\n\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 PyMethodDef __pyx_mdef_5trade_5Trade_17peak_offers = {"peak_offers", (PyCFunction)__pyx_pw_5trade_5Trade_17peak_offers, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_16peak_offers}; +static PyObject *__pyx_pw_5trade_5Trade_17peak_offers(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_good = 0; PyObject *__pyx_v_sorted = 0; @@ -7248,7 +6122,7 @@ static PyObject *__pyx_pw_5trade_5Trade_23peak_offers(PyObject *__pyx_self, PyOb case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_good)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("peak_offers", 0, 2, 5, 1); __PYX_ERR(0, 383, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("peak_offers", 0, 2, 5, 1); __PYX_ERR(0, 464, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: @@ -7270,7 +6144,7 @@ static PyObject *__pyx_pw_5trade_5Trade_23peak_offers(PyObject *__pyx_self, PyOb } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "peak_offers") < 0)) __PYX_ERR(0, 383, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "peak_offers") < 0)) __PYX_ERR(0, 464, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -7294,20 +6168,20 @@ static PyObject *__pyx_pw_5trade_5Trade_23peak_offers(PyObject *__pyx_self, PyOb } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("peak_offers", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 383, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("peak_offers", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 464, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade.peak_offers", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5trade_5Trade_22peak_offers(__pyx_self, __pyx_v_self, __pyx_v_good, __pyx_v_sorted, __pyx_v_descending, __pyx_v_shuffled); + __pyx_r = __pyx_pf_5trade_5Trade_16peak_offers(__pyx_self, __pyx_v_self, __pyx_v_good, __pyx_v_sorted, __pyx_v_descending, __pyx_v_shuffled); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "trade.pyx":413 +/* "trade.pyx":506 * random.shuffle(ret) * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) # <<<<<<<<<<<<<< @@ -7316,26 +6190,26 @@ static PyObject *__pyx_pw_5trade_5Trade_23peak_offers(PyObject *__pyx_self, PyOb */ /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_11peak_offers_lambda5(PyObject *__pyx_self, PyObject *__pyx_v_objects); /*proto*/ -static PyMethodDef __pyx_mdef_5trade_5Trade_11peak_offers_lambda5 = {"lambda5", (PyCFunction)__pyx_pw_5trade_5Trade_11peak_offers_lambda5, METH_O, 0}; -static PyObject *__pyx_pw_5trade_5Trade_11peak_offers_lambda5(PyObject *__pyx_self, PyObject *__pyx_v_objects) { +static PyObject *__pyx_pw_5trade_5Trade_11peak_offers_lambda3(PyObject *__pyx_self, PyObject *__pyx_v_objects); /*proto*/ +static PyMethodDef __pyx_mdef_5trade_5Trade_11peak_offers_lambda3 = {"lambda3", (PyCFunction)__pyx_pw_5trade_5Trade_11peak_offers_lambda3, METH_O, 0}; +static PyObject *__pyx_pw_5trade_5Trade_11peak_offers_lambda3(PyObject *__pyx_self, PyObject *__pyx_v_objects) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("lambda5 (wrapper)", 0); - __pyx_r = __pyx_lambda_funcdef_lambda5(__pyx_self, ((PyObject *)__pyx_v_objects)); + __Pyx_RefNannySetupContext("lambda3 (wrapper)", 0); + __pyx_r = __pyx_lambda_funcdef_lambda3(__pyx_self, ((PyObject *)__pyx_v_objects)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_lambda_funcdef_lambda5(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objects) { +static PyObject *__pyx_lambda_funcdef_lambda3(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objects) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("lambda5", 0); + __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, 413, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_objects, __pyx_n_s_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 506, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -7344,7 +6218,7 @@ static PyObject *__pyx_lambda_funcdef_lambda5(CYTHON_UNUSED PyObject *__pyx_self /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("trade.Trade.peak_offers.lambda5", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("trade.Trade.peak_offers.lambda3", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -7352,7 +6226,7 @@ static PyObject *__pyx_lambda_funcdef_lambda5(CYTHON_UNUSED PyObject *__pyx_self return __pyx_r; } -/* "trade.pyx":383 +/* "trade.pyx":464 * return ret * * def peak_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< @@ -7360,191 +6234,237 @@ static PyObject *__pyx_lambda_funcdef_lambda5(CYTHON_UNUSED PyObject *__pyx_self * Peaked offers can not be accepted or rejected and they do not */ -static PyObject *__pyx_pf_5trade_5Trade_22peak_offers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_good, PyObject *__pyx_v_sorted, PyObject *__pyx_v_descending, PyObject *__pyx_v_shuffled) { +static PyObject *__pyx_pf_5trade_5Trade_16peak_offers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_good, PyObject *__pyx_v_sorted, PyObject *__pyx_v_descending, PyObject *__pyx_v_shuffled) { PyObject *__pyx_v_ret = NULL; + PyObject *__pyx_v_offer = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_4; + PyObject *(*__pyx_t_5)(PyObject *); int __pyx_t_6; + int __pyx_t_7; + PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("peak_offers", 0); - /* "trade.pyx":408 + /* "trade.pyx":500 * 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: + * ret = [] # <<<<<<<<<<<<<< + * for offer in self._open_offers_sell[good].values(): + * ret.append(offer) */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_peak_buy_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 408, __pyx_L1_error) + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 500, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 408, __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 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 408, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_sorted, Py_False) < 0) __PYX_ERR(0, 408, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_descending, Py_False) < 0) __PYX_ERR(0, 408, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_shuffled, Py_False) < 0) __PYX_ERR(0, 408, __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, 408, __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; + __pyx_v_ret = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; - /* "trade.pyx":409 + /* "trade.pyx":501 * """ - * ret = (self.peak_buy_offers(good, sorted=False, descending=False, shuffled=False) + - * self.peak_sell_offers(good, sorted=False, descending=False, shuffled=False)) # <<<<<<<<<<<<<< + * ret = [] + * for offer in self._open_offers_sell[good].values(): # <<<<<<<<<<<<<< + * ret.append(offer) * if shuffled: - * random.shuffle(ret) */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_peak_sell_offers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 409, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_open_offers_sell); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 501, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 501, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 409, __pyx_L1_error) + __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, 501, __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 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 409, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_sorted, Py_False) < 0) __PYX_ERR(0, 409, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_descending, Py_False) < 0) __PYX_ERR(0, 409, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_shuffled, Py_False) < 0) __PYX_ERR(0, 409, __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, 409, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (__pyx_t_3) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 501, __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, 501, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { + __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, 501, __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, 501, __pyx_L1_error) + } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + for (;;) { + if (likely(!__pyx_t_5)) { + 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, 501, __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, 501, __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, 501, __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, 501, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + #endif + } + } else { + __pyx_t_1 = __pyx_t_5(__pyx_t_2); + if (unlikely(!__pyx_t_1)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 501, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_1); + } + __Pyx_XDECREF_SET(__pyx_v_offer, __pyx_t_1); + __pyx_t_1 = 0; - /* "trade.pyx":408 - * self.reject(offer) # optional + /* "trade.pyx":502 + * 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 == ((int)-1))) __PYX_ERR(0, 502, __pyx_L1_error) + + /* "trade.pyx":501 * """ - * ret = (self.peak_buy_offers(good, sorted=False, descending=False, shuffled=False) + # <<<<<<<<<<<<<< - * self.peak_sell_offers(good, sorted=False, descending=False, shuffled=False)) + * ret = [] + * for offer in self._open_offers_sell[good].values(): # <<<<<<<<<<<<<< + * ret.append(offer) * if shuffled: */ - __pyx_t_1 = PyNumber_Add(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 408, __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; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":410 - * ret = (self.peak_buy_offers(good, sorted=False, descending=False, shuffled=False) + - * self.peak_sell_offers(good, sorted=False, descending=False, shuffled=False)) + /* "trade.pyx":503 + * for offer in self._open_offers_sell[good].values(): + * ret.append(offer) * 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, 410, __pyx_L1_error) - if (__pyx_t_6) { + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_shuffled); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 503, __pyx_L1_error) + if (__pyx_t_7) { - /* "trade.pyx":411 - * self.peak_sell_offers(good, sorted=False, descending=False, shuffled=False)) + /* "trade.pyx":504 + * ret.append(offer) * 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, 411, __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, 411, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(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_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 504, __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, 504, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_1)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); + __Pyx_DECREF_SET(__pyx_t_3, function); } } - if (!__pyx_t_5) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_ret); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 411, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + if (!__pyx_t_1) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_ret); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 504, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); } 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, 411, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_1); + 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, 504, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_GOTREF(__pyx_t_2); } else #endif #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, 411, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_1); + 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, 504, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_GOTREF(__pyx_t_2); } else #endif { - __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 411, __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_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 504, __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_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, 411, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + 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, 504, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":410 - * ret = (self.peak_buy_offers(good, sorted=False, descending=False, shuffled=False) + - * self.peak_sell_offers(good, sorted=False, descending=False, shuffled=False)) + /* "trade.pyx":503 + * for offer in self._open_offers_sell[good].values(): + * ret.append(offer) * if shuffled: # <<<<<<<<<<<<<< * random.shuffle(ret) * if sorted: */ } - /* "trade.pyx":412 + /* "trade.pyx":505 * 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, 412, __pyx_L1_error) - if (__pyx_t_6) { + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_sorted); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 505, __pyx_L1_error) + if (__pyx_t_7) { - /* "trade.pyx":413 + /* "trade.pyx":506 * 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, 413, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 413, __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_Trade_peak_offers_locals_lambda, NULL, __pyx_n_s_trade, __pyx_d, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 413, __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, 413, __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, 413, __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, 413, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ret, __pyx_n_s_sort); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 506, __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_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 506, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_8 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_11peak_offers_lambda3, 0, __pyx_n_s_Trade_peak_offers_locals_lambda, NULL, __pyx_n_s_trade, __pyx_d, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 506, __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, 506, __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, 506, __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, 506, __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":412 + /* "trade.pyx":505 * if shuffled: * random.shuffle(ret) * if sorted: # <<<<<<<<<<<<<< @@ -7553,19 +6473,19 @@ static PyObject *__pyx_pf_5trade_5Trade_22peak_offers(CYTHON_UNUSED PyObject *__ */ } - /* "trade.pyx":414 + /* "trade.pyx":507 * if sorted: * ret.sort(key=lambda objects: objects.price, reverse=descending) * return ret # <<<<<<<<<<<<<< * - * def sell(self, receiver, + * def make_offer(self, receiver, */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_ret); __pyx_r = __pyx_v_ret; goto __pyx_L0; - /* "trade.pyx":383 + /* "trade.pyx":464 * return ret * * def peak_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< @@ -7578,22 +6498,22 @@ static PyObject *__pyx_pf_5trade_5Trade_22peak_offers(CYTHON_UNUSED PyObject *__ __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("trade.Trade.peak_offers", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_ret); + __Pyx_XDECREF(__pyx_v_offer); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "trade.pyx":416 +/* "trade.pyx":509 * return ret * - * def sell(self, receiver, # <<<<<<<<<<<<<< - * good, double quantity, double price, str currency='money', double epsilon=epsilon): + * def make_offer(self, receiver, # <<<<<<<<<<<<<< + * good, double quantity, double price, str currency='money', double epsilon=epsilon): * """ commits to sell the quantity of good at price */ @@ -7604,9 +6524,9 @@ static PyObject *__pyx_pf_5trade_4__defaults__(CYTHON_UNUSED PyObject *__pyx_sel PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("__defaults__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(__Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self)->__pyx_arg_epsilon); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 416, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(__Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self)->__pyx_arg_epsilon); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 416, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject*)__pyx_n_s_money)); __Pyx_GIVEREF(((PyObject*)__pyx_n_s_money)); @@ -7614,7 +6534,7 @@ static PyObject *__pyx_pf_5trade_4__defaults__(CYTHON_UNUSED PyObject *__pyx_sel __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 416, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); @@ -7639,10 +6559,10 @@ static PyObject *__pyx_pf_5trade_4__defaults__(CYTHON_UNUSED PyObject *__pyx_sel } /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_25sell(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_5trade_5Trade_24sell[] = " commits to sell the quantity of good at price\n\n The good is not available for the agent. When the offer is\n rejected it is automatically re-credited. When the offer is\n accepted the money amount is credited. (partial acceptance\n accordingly)\n\n Args:\n receiver_group:\n group of the receiving agent\n\n receiver_id:\n number of the receiving agent\n\n 'good':\n name of the good\n\n quantity:\n maximum units disposed to buy at this price\n\n price:\n price per unit\n\n currency:\n is the currency of this transaction (defaults to 'money')\n\n epsilon (optional):\n if you have floating point errors, a quantity or prices is\n a fraction of number to high or low. You can increase the\n floating point tolerance. See troubleshooting -- floating point problems\n\n Returns:\n A reference to the offer. The offer and the offer status can\n be accessed with `self.info(offer_reference)`.\n\n Example::\n\n def subround_1(self):\n self.offer = self.sell('household', 1, 'cookies', quantity=5, price=0.1)\n\n def subround_2(self):\n offer = self.info(self.offer)\n if offer.status == 'accepted':\n print(offer.final_quantity , 'cookies have be bougth')\n else:\n offer.status == 'rejected':\n print('On diet')\n "; -static PyMethodDef __pyx_mdef_5trade_5Trade_25sell = {"sell", (PyCFunction)__pyx_pw_5trade_5Trade_25sell, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_24sell}; -static PyObject *__pyx_pw_5trade_5Trade_25sell(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5trade_5Trade_19make_offer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5trade_5Trade_18make_offer[] = " commits to sell the quantity of good at price\n\n The good is not available for the agent. When the offer is\n rejected it is automatically re-credited. When the offer is\n accepted the money amount is credited. (partial acceptance\n accordingly)\n\n Args:\n receiver_group:\n group of the receiving agent\n\n receiver_id:\n number of the receiving agent\n\n 'good':\n name of the good\n\n quantity:\n maximum units disposed to buy at this price\n\n price:\n price per unit\n\n currency:\n is the currency of this transaction (defaults to 'money')\n\n epsilon (optional):\n if you have floating point errors, a quantity or prices is\n a fraction of number to high or low. You can increase the\n floating point tolerance. See troubleshooting -- floating point problems\n\n Returns:\n A reference to the offer. The offer and the offer status can\n be accessed with `self.info(offer_reference)`.\n\n Example::\n\n def subround_1(self):\n self.offer = self.make_offer('household', 1, 'cookies', quantity=5, price=0.1)\n\n def subround_2(self):\n offer = self.info(self.offer)\n if offer.status == 'accepted':\n print(offer.final_quantity , 'cookies have be bougth')\n else:\n offer.status == 'rejected':\n print('On diet')\n "; +static PyMethodDef __pyx_mdef_5trade_5Trade_19make_offer = {"make_offer", (PyCFunction)__pyx_pw_5trade_5Trade_19make_offer, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_18make_offer}; +static PyObject *__pyx_pw_5trade_5Trade_19make_offer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_receiver = 0; PyObject *__pyx_v_good = 0; @@ -7652,7 +6572,7 @@ static PyObject *__pyx_pw_5trade_5Trade_25sell(PyObject *__pyx_self, PyObject *_ double __pyx_v_epsilon; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("sell (wrapper)", 0); + __Pyx_RefNannySetupContext("make_offer (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_receiver,&__pyx_n_s_good,&__pyx_n_s_quantity,&__pyx_n_s_price,&__pyx_n_s_currency,&__pyx_n_s_epsilon,0}; PyObject* values[7] = {0,0,0,0,0,0,0}; @@ -7688,25 +6608,25 @@ static PyObject *__pyx_pw_5trade_5Trade_25sell(PyObject *__pyx_self, PyObject *_ case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_receiver)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("sell", 0, 5, 7, 1); __PYX_ERR(0, 416, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("make_offer", 0, 5, 7, 1); __PYX_ERR(0, 509, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_good)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("sell", 0, 5, 7, 2); __PYX_ERR(0, 416, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("make_offer", 0, 5, 7, 2); __PYX_ERR(0, 509, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_quantity)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("sell", 0, 5, 7, 3); __PYX_ERR(0, 416, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("make_offer", 0, 5, 7, 3); __PYX_ERR(0, 509, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_price)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("sell", 0, 5, 7, 4); __PYX_ERR(0, 416, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("make_offer", 0, 5, 7, 4); __PYX_ERR(0, 509, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: @@ -7722,7 +6642,7 @@ static PyObject *__pyx_pw_5trade_5Trade_25sell(PyObject *__pyx_self, PyObject *_ } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sell") < 0)) __PYX_ERR(0, 416, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "make_offer") < 0)) __PYX_ERR(0, 509, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -7742,25 +6662,25 @@ static PyObject *__pyx_pw_5trade_5Trade_25sell(PyObject *__pyx_self, PyObject *_ __pyx_v_self = values[0]; __pyx_v_receiver = values[1]; __pyx_v_good = values[2]; - __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 417, __pyx_L3_error) - __pyx_v_price = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_price == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 417, __pyx_L3_error) + __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 510, __pyx_L3_error) + __pyx_v_price = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_price == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 510, __pyx_L3_error) __pyx_v_currency = ((PyObject*)values[5]); if (values[6]) { - __pyx_v_epsilon = __pyx_PyFloat_AsDouble(values[6]); if (unlikely((__pyx_v_epsilon == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 417, __pyx_L3_error) + __pyx_v_epsilon = __pyx_PyFloat_AsDouble(values[6]); if (unlikely((__pyx_v_epsilon == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 510, __pyx_L3_error) } else { __pyx_v_epsilon = __pyx_dynamic_args->__pyx_arg_epsilon; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("sell", 0, 5, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 416, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("make_offer", 0, 5, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 509, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("trade.Trade.sell", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("trade.Trade.make_offer", __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, 417, __pyx_L1_error) - __pyx_r = __pyx_pf_5trade_5Trade_24sell(__pyx_self, __pyx_v_self, __pyx_v_receiver, __pyx_v_good, __pyx_v_quantity, __pyx_v_price, __pyx_v_currency, __pyx_v_epsilon); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_currency), (&PyString_Type), 1, "currency", 1))) __PYX_ERR(0, 510, __pyx_L1_error) + __pyx_r = __pyx_pf_5trade_5Trade_18make_offer(__pyx_self, __pyx_v_self, __pyx_v_receiver, __pyx_v_good, __pyx_v_quantity, __pyx_v_price, __pyx_v_currency, __pyx_v_epsilon); /* function exit code */ goto __pyx_L0; @@ -7771,7 +6691,7 @@ static PyObject *__pyx_pw_5trade_5Trade_25sell(PyObject *__pyx_self, PyObject *_ return __pyx_r; } -static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_receiver, PyObject *__pyx_v_good, double __pyx_v_quantity, double __pyx_v_price, PyObject *__pyx_v_currency, double __pyx_v_epsilon) { +static PyObject *__pyx_pf_5trade_5Trade_18make_offer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_receiver, PyObject *__pyx_v_good, double __pyx_v_quantity, double __pyx_v_price, PyObject *__pyx_v_currency, double __pyx_v_epsilon) { double __pyx_v_available; PyObject *__pyx_v_offer_id = NULL; struct __pyx_obj_5trade_Offer *__pyx_v_offer = 0; @@ -7786,9 +6706,9 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel PyObject *__pyx_t_7 = NULL; int __pyx_t_8; PyObject *__pyx_t_9 = NULL; - __Pyx_RefNannySetupContext("sell", 0); + __Pyx_RefNannySetupContext("make_offer", 0); - /* "trade.pyx":467 + /* "trade.pyx":560 * """ * cdef double available * assert price > - epsilon, 'price %.30f is smaller than 0 - epsilon (%.30f)' % (price, - epsilon) # <<<<<<<<<<<<<< @@ -7798,11 +6718,11 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel #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, 467, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 560, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 467, __pyx_L1_error) + __pyx_t_2 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 560, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 467, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 560, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); @@ -7810,17 +6730,17 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel 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, 467, __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, 560, __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, 467, __pyx_L1_error) + __PYX_ERR(0, 560, __pyx_L1_error) } } #endif - /* "trade.pyx":468 + /* "trade.pyx":561 * cdef double available * assert price > - epsilon, 'price %.30f is smaller than 0 - epsilon (%.30f)' % (price, - epsilon) * if price < 0: # <<<<<<<<<<<<<< @@ -7830,7 +6750,7 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_4 = ((__pyx_v_price < 0.0) != 0); if (__pyx_t_4) { - /* "trade.pyx":469 + /* "trade.pyx":562 * assert price > - epsilon, 'price %.30f is smaller than 0 - epsilon (%.30f)' % (price, - epsilon) * if price < 0: * price = 0 # <<<<<<<<<<<<<< @@ -7839,7 +6759,7 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel */ __pyx_v_price = 0.0; - /* "trade.pyx":468 + /* "trade.pyx":561 * cdef double available * assert price > - epsilon, 'price %.30f is smaller than 0 - epsilon (%.30f)' % (price, - epsilon) * if price < 0: # <<<<<<<<<<<<<< @@ -7848,23 +6768,23 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel */ } - /* "trade.pyx":472 + /* "trade.pyx":565 * # 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._inventory[good] # <<<<<<<<<<<<<< * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 472, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 565, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 472, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 565, __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, 472, __pyx_L1_error) + __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 565, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_available = __pyx_t_5; - /* "trade.pyx":473 + /* "trade.pyx":566 * # if its only a little bit above or below its set to the bounds * available = self._inventory[good] * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) # <<<<<<<<<<<<<< @@ -7874,11 +6794,11 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel #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, 473, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 566, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 473, __pyx_L1_error) + __pyx_t_2 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 566, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 473, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 566, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); @@ -7886,17 +6806,17 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel 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, 473, __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, 566, __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, 473, __pyx_L1_error) + __PYX_ERR(0, 566, __pyx_L1_error) } } #endif - /* "trade.pyx":474 + /* "trade.pyx":567 * available = self._inventory[good] * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: # <<<<<<<<<<<<<< @@ -7906,7 +6826,7 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_4 = ((__pyx_v_quantity < 0.0) != 0); if (__pyx_t_4) { - /* "trade.pyx":475 + /* "trade.pyx":568 * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: * quantity = 0 # <<<<<<<<<<<<<< @@ -7915,7 +6835,7 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel */ __pyx_v_quantity = 0.0; - /* "trade.pyx":474 + /* "trade.pyx":567 * available = self._inventory[good] * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: # <<<<<<<<<<<<<< @@ -7924,7 +6844,7 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel */ } - /* "trade.pyx":476 + /* "trade.pyx":569 * if quantity < 0: * quantity = 0 * if quantity > available + epsilon + epsilon * fmax(quantity, available): # <<<<<<<<<<<<<< @@ -7934,18 +6854,18 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel __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 (unlikely(__pyx_t_4)) { - /* "trade.pyx":477 + /* "trade.pyx":570 * 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, 477, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_NotEnoughGoods); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 570, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 477, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 570, __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, 477, __pyx_L1_error) + __pyx_t_6 = PyFloat_FromDouble((__pyx_v_quantity - __pyx_v_available)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 570, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_8 = 0; @@ -7962,7 +6882,7 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel #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, 477, __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, 570, __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; @@ -7972,7 +6892,7 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel #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, 477, __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, 570, __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; @@ -7980,7 +6900,7 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel } else #endif { - __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 477, __pyx_L1_error) + __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 570, __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; @@ -7994,16 +6914,16 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel 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, 477, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 570, __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, 477, __pyx_L1_error) + __PYX_ERR(0, 570, __pyx_L1_error) - /* "trade.pyx":476 + /* "trade.pyx":569 * if quantity < 0: * quantity = 0 * if quantity > available + epsilon + epsilon * fmax(quantity, available): # <<<<<<<<<<<<<< @@ -8012,7 +6932,7 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel */ } - /* "trade.pyx":478 + /* "trade.pyx":571 * if quantity > available + epsilon + epsilon * fmax(quantity, available): * raise NotEnoughGoods(self.name, good, quantity - available) * if quantity > available: # <<<<<<<<<<<<<< @@ -8022,7 +6942,7 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_4 = ((__pyx_v_quantity > __pyx_v_available) != 0); if (__pyx_t_4) { - /* "trade.pyx":479 + /* "trade.pyx":572 * raise NotEnoughGoods(self.name, good, quantity - available) * if quantity > available: * quantity = available # <<<<<<<<<<<<<< @@ -8031,7 +6951,7 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel */ __pyx_v_quantity = __pyx_v_available; - /* "trade.pyx":478 + /* "trade.pyx":571 * if quantity > available + epsilon + epsilon * fmax(quantity, available): * raise NotEnoughGoods(self.name, good, quantity - available) * if quantity > available: # <<<<<<<<<<<<<< @@ -8040,14 +6960,14 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel */ } - /* "trade.pyx":481 + /* "trade.pyx":574 * quantity = available * * offer_id = self._offer_counter() # <<<<<<<<<<<<<< * self._inventory.reserve(good, quantity) * cdef Offer offer = Offer(self.name, */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_offer_counter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 481, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_offer_counter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 574, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { @@ -8060,29 +6980,29 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel } } if (__pyx_t_9) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 481, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 574, __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, 481, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 574, __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":482 + /* "trade.pyx":575 * * offer_id = self._offer_counter() * self._inventory.reserve(good, quantity) # <<<<<<<<<<<<<< * cdef Offer offer = Offer(self.name, * receiver, */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 482, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 575, __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, 482, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_reserve); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 575, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __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, 482, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 575, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = NULL; __pyx_t_8 = 0; @@ -8099,7 +7019,7 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel #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, 482, __pyx_L1_error) + __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, 575, __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; @@ -8108,14 +7028,14 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel #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, 482, __pyx_L1_error) + __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, 575, __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, 482, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 575, __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; @@ -8126,61 +7046,61 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel __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, 482, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 575, __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":483 + /* "trade.pyx":576 * offer_id = self._offer_counter() * self._inventory.reserve(good, quantity) * cdef Offer offer = Offer(self.name, # <<<<<<<<<<<<<< * receiver, * good, */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 483, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 576, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - /* "trade.pyx":486 + /* "trade.pyx":579 * receiver, * good, * quantity, # <<<<<<<<<<<<<< * price, * currency, */ - __pyx_t_9 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 486, __pyx_L1_error) + __pyx_t_9 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 579, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - /* "trade.pyx":487 + /* "trade.pyx":580 * good, * quantity, * price, # <<<<<<<<<<<<<< * currency, * True, */ - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_price); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 487, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_price); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 580, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - /* "trade.pyx":493 + /* "trade.pyx":586 * -2, * offer_id, * self.time, # <<<<<<<<<<<<<< * -2) * self.given_offers[offer_id] = offer */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_time); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 493, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_time); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 586, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - /* "trade.pyx":483 + /* "trade.pyx":576 * offer_id = self._offer_counter() * self._inventory.reserve(good, quantity) * cdef Offer offer = Offer(self.name, # <<<<<<<<<<<<<< * receiver, * good, */ - __pyx_t_6 = PyTuple_New(12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 483, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 576, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); @@ -8218,32 +7138,32 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_9 = 0; __pyx_t_3 = 0; __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5trade_Offer), __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 483, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5trade_Offer), __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 576, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_offer = ((struct __pyx_obj_5trade_Offer *)__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":495 + /* "trade.pyx":588 * self.time, * -2) * self.given_offers[offer_id] = offer # <<<<<<<<<<<<<< * self._send(receiver, 'abce_propose_sell', offer) * return offer */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_given_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 495, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_given_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 588, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_offer_id, ((PyObject *)__pyx_v_offer)) < 0)) __PYX_ERR(0, 495, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_offer_id, ((PyObject *)__pyx_v_offer)) < 0)) __PYX_ERR(0, 588, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":496 + /* "trade.pyx":589 * -2) * self.given_offers[offer_id] = offer * self._send(receiver, 'abce_propose_sell', offer) # <<<<<<<<<<<<<< * return offer * */ - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_send); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 496, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_send); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 589, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = NULL; __pyx_t_8 = 0; @@ -8260,7 +7180,7 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_v_receiver, __pyx_n_s_abce_propose_sell, ((PyObject *)__pyx_v_offer)}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 496, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 589, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else @@ -8268,13 +7188,13 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_v_receiver, __pyx_n_s_abce_propose_sell, ((PyObject *)__pyx_v_offer)}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 496, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 589, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { - __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 496, __pyx_L1_error) + __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 589, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3); __pyx_t_3 = NULL; @@ -8288,30 +7208,30 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel __Pyx_INCREF(((PyObject *)__pyx_v_offer)); __Pyx_GIVEREF(((PyObject *)__pyx_v_offer)); PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, ((PyObject *)__pyx_v_offer)); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 496, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 589, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":497 + /* "trade.pyx":590 * self.given_offers[offer_id] = offer * self._send(receiver, 'abce_propose_sell', offer) * return offer # <<<<<<<<<<<<<< * - * def buy(self, receiver, good, + * def make_bid(self, receiver, good, */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__pyx_v_offer)); __pyx_r = ((PyObject *)__pyx_v_offer); goto __pyx_L0; - /* "trade.pyx":416 + /* "trade.pyx":509 * return ret * - * def sell(self, receiver, # <<<<<<<<<<<<<< - * good, double quantity, double price, str currency='money', double epsilon=epsilon): + * def make_offer(self, receiver, # <<<<<<<<<<<<<< + * good, double quantity, double price, str currency='money', double epsilon=epsilon): * """ commits to sell the quantity of good at price */ @@ -8323,7 +7243,7 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); - __Pyx_AddTraceback("trade.Trade.sell", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("trade.Trade.make_offer", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_offer_id); @@ -8333,10 +7253,10 @@ static PyObject *__pyx_pf_5trade_5Trade_24sell(CYTHON_UNUSED PyObject *__pyx_sel return __pyx_r; } -/* "trade.pyx":499 +/* "trade.pyx":592 * return offer * - * def buy(self, receiver, good, # <<<<<<<<<<<<<< + * def make_bid(self, receiver, good, # <<<<<<<<<<<<<< * double quantity, double price, str currency='money', double epsilon=epsilon): * """ commits to sell the quantity of good at price */ @@ -8348,9 +7268,9 @@ static PyObject *__pyx_pf_5trade_6__defaults__(CYTHON_UNUSED PyObject *__pyx_sel PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("__defaults__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(__Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_self)->__pyx_arg_epsilon); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 499, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(__Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_self)->__pyx_arg_epsilon); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 592, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 499, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 592, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject*)__pyx_n_s_money)); __Pyx_GIVEREF(((PyObject*)__pyx_n_s_money)); @@ -8358,7 +7278,7 @@ static PyObject *__pyx_pf_5trade_6__defaults__(CYTHON_UNUSED PyObject *__pyx_sel __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 499, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 592, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); @@ -8383,10 +7303,10 @@ static PyObject *__pyx_pf_5trade_6__defaults__(CYTHON_UNUSED PyObject *__pyx_sel } /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_27buy(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_5trade_5Trade_26buy[] = " commits to sell the quantity of good at price\n\n The goods are not in haves or self.count(). When the offer is\n rejected it is automatically re-credited. When the offer is\n accepted the money amount is credited. (partial acceptance\n accordingly)\n\n Args:\n receiver:\n The name of the receiving agent a tuple (group, id).\n e.G. ('firm', 15)\n\n 'good':\n name of the good\n\n quantity:\n maximum units disposed to buy at this price\n\n price:\n price per unit\n\n currency:\n is the currency of this transaction (defaults to 'money')\n\n epsilon (optional):\n if you have floating point errors, a quantity or prices is\n a fraction of number to high or low. You can increase the\n floating point tolerance. See troubleshooting -- floating point problems\n "; -static PyMethodDef __pyx_mdef_5trade_5Trade_27buy = {"buy", (PyCFunction)__pyx_pw_5trade_5Trade_27buy, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_26buy}; -static PyObject *__pyx_pw_5trade_5Trade_27buy(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5trade_5Trade_21make_bid(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5trade_5Trade_20make_bid[] = " commits to sell the quantity of good at price\n\n The goods are not in haves or self.count(). When the offer is\n rejected it is automatically re-credited. When the offer is\n accepted the money amount is credited. (partial acceptance\n accordingly)\n\n Args:\n receiver:\n The name of the receiving agent a tuple (group, id).\n e.G. ('firm', 15)\n\n 'good':\n name of the good\n\n quantity:\n maximum units available to buy at this price\n\n price:\n price per unit\n\n currency:\n is the currency of this transaction (defaults to 'money')\n\n epsilon (optional):\n if you have floating point errors, a quantity or prices is\n a fraction of number to high or low. You can increase the\n floating point tolerance. See troubleshooting -- floating point problems\n "; +static PyMethodDef __pyx_mdef_5trade_5Trade_21make_bid = {"make_bid", (PyCFunction)__pyx_pw_5trade_5Trade_21make_bid, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_20make_bid}; +static PyObject *__pyx_pw_5trade_5Trade_21make_bid(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_receiver = 0; PyObject *__pyx_v_good = 0; @@ -8396,7 +7316,7 @@ static PyObject *__pyx_pw_5trade_5Trade_27buy(PyObject *__pyx_self, PyObject *__ double __pyx_v_epsilon; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("buy (wrapper)", 0); + __Pyx_RefNannySetupContext("make_bid (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_receiver,&__pyx_n_s_good,&__pyx_n_s_quantity,&__pyx_n_s_price,&__pyx_n_s_currency,&__pyx_n_s_epsilon,0}; PyObject* values[7] = {0,0,0,0,0,0,0}; @@ -8432,25 +7352,25 @@ static PyObject *__pyx_pw_5trade_5Trade_27buy(PyObject *__pyx_self, PyObject *__ case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_receiver)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("buy", 0, 5, 7, 1); __PYX_ERR(0, 499, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("make_bid", 0, 5, 7, 1); __PYX_ERR(0, 592, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_good)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("buy", 0, 5, 7, 2); __PYX_ERR(0, 499, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("make_bid", 0, 5, 7, 2); __PYX_ERR(0, 592, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_quantity)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("buy", 0, 5, 7, 3); __PYX_ERR(0, 499, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("make_bid", 0, 5, 7, 3); __PYX_ERR(0, 592, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_price)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("buy", 0, 5, 7, 4); __PYX_ERR(0, 499, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("make_bid", 0, 5, 7, 4); __PYX_ERR(0, 592, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: @@ -8466,7 +7386,7 @@ static PyObject *__pyx_pw_5trade_5Trade_27buy(PyObject *__pyx_self, PyObject *__ } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "buy") < 0)) __PYX_ERR(0, 499, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "make_bid") < 0)) __PYX_ERR(0, 592, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -8486,25 +7406,25 @@ static PyObject *__pyx_pw_5trade_5Trade_27buy(PyObject *__pyx_self, PyObject *__ __pyx_v_self = values[0]; __pyx_v_receiver = values[1]; __pyx_v_good = values[2]; - __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 500, __pyx_L3_error) - __pyx_v_price = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_price == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 500, __pyx_L3_error) + __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 593, __pyx_L3_error) + __pyx_v_price = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_price == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 593, __pyx_L3_error) __pyx_v_currency = ((PyObject*)values[5]); if (values[6]) { - __pyx_v_epsilon = __pyx_PyFloat_AsDouble(values[6]); if (unlikely((__pyx_v_epsilon == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 500, __pyx_L3_error) + __pyx_v_epsilon = __pyx_PyFloat_AsDouble(values[6]); if (unlikely((__pyx_v_epsilon == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 593, __pyx_L3_error) } else { __pyx_v_epsilon = __pyx_dynamic_args->__pyx_arg_epsilon; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("buy", 0, 5, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 499, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("make_bid", 0, 5, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 592, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("trade.Trade.buy", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("trade.Trade.make_bid", __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, 500, __pyx_L1_error) - __pyx_r = __pyx_pf_5trade_5Trade_26buy(__pyx_self, __pyx_v_self, __pyx_v_receiver, __pyx_v_good, __pyx_v_quantity, __pyx_v_price, __pyx_v_currency, __pyx_v_epsilon); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_currency), (&PyString_Type), 1, "currency", 1))) __PYX_ERR(0, 593, __pyx_L1_error) + __pyx_r = __pyx_pf_5trade_5Trade_20make_bid(__pyx_self, __pyx_v_self, __pyx_v_receiver, __pyx_v_good, __pyx_v_quantity, __pyx_v_price, __pyx_v_currency, __pyx_v_epsilon); /* function exit code */ goto __pyx_L0; @@ -8515,7 +7435,7 @@ static PyObject *__pyx_pw_5trade_5Trade_27buy(PyObject *__pyx_self, PyObject *__ return __pyx_r; } -static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_receiver, PyObject *__pyx_v_good, double __pyx_v_quantity, double __pyx_v_price, PyObject *__pyx_v_currency, double __pyx_v_epsilon) { +static PyObject *__pyx_pf_5trade_5Trade_20make_bid(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_receiver, PyObject *__pyx_v_good, double __pyx_v_quantity, double __pyx_v_price, PyObject *__pyx_v_currency, double __pyx_v_epsilon) { double __pyx_v_available; double __pyx_v_money_amount; PyObject *__pyx_v_offer_id = NULL; @@ -8530,9 +7450,9 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self PyObject *__pyx_t_6 = NULL; int __pyx_t_7; PyObject *__pyx_t_8 = NULL; - __Pyx_RefNannySetupContext("buy", 0); + __Pyx_RefNannySetupContext("make_bid", 0); - /* "trade.pyx":532 + /* "trade.pyx":625 * cdef double available * cdef double money_amount * assert price > - epsilon, 'price %.30f is smaller than 0 - epsilon (%.30f)' % (price, - epsilon) # <<<<<<<<<<<<<< @@ -8542,11 +7462,11 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self #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, 532, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_price); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 532, __pyx_L1_error) + __pyx_t_2 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 532, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); @@ -8554,17 +7474,17 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self 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, 532, __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, 625, __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, 532, __pyx_L1_error) + __PYX_ERR(0, 625, __pyx_L1_error) } } #endif - /* "trade.pyx":533 + /* "trade.pyx":626 * cdef double money_amount * assert price > - epsilon, 'price %.30f is smaller than 0 - epsilon (%.30f)' % (price, - epsilon) * if price < 0: # <<<<<<<<<<<<<< @@ -8574,7 +7494,7 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_4 = ((__pyx_v_price < 0.0) != 0); if (__pyx_t_4) { - /* "trade.pyx":534 + /* "trade.pyx":627 * assert price > - epsilon, 'price %.30f is smaller than 0 - epsilon (%.30f)' % (price, - epsilon) * if price < 0: * price = 0 # <<<<<<<<<<<<<< @@ -8583,7 +7503,7 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self */ __pyx_v_price = 0.0; - /* "trade.pyx":533 + /* "trade.pyx":626 * cdef double money_amount * assert price > - epsilon, 'price %.30f is smaller than 0 - epsilon (%.30f)' % (price, - epsilon) * if price < 0: # <<<<<<<<<<<<<< @@ -8592,7 +7512,7 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self */ } - /* "trade.pyx":535 + /* "trade.pyx":628 * if price < 0: * price = 0 * money_amount = quantity * price # <<<<<<<<<<<<<< @@ -8601,23 +7521,23 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self */ __pyx_v_money_amount = (__pyx_v_quantity * __pyx_v_price); - /* "trade.pyx":538 + /* "trade.pyx":631 * # 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._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(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 538, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_t_2, __pyx_v_currency); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 538, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_t_2, __pyx_v_currency); 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_5 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 538, __pyx_L1_error) + __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_available = __pyx_t_5; - /* "trade.pyx":539 + /* "trade.pyx":632 * # if its only a little bit above or below its set to the bounds * available = self._inventory[currency] * assert money_amount > - epsilon, '%s (price * quantity) %.30f is smaller than 0 - epsilon (%.30f)' % (currency, money_amount, - epsilon) # <<<<<<<<<<<<<< @@ -8627,11 +7547,11 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self #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, 539, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_money_amount); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 632, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 539, __pyx_L1_error) + __pyx_t_2 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 632, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 539, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 632, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_currency); __Pyx_GIVEREF(__pyx_v_currency); @@ -8642,17 +7562,17 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self 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, 539, __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, 632, __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, 539, __pyx_L1_error) + __PYX_ERR(0, 632, __pyx_L1_error) } } #endif - /* "trade.pyx":540 + /* "trade.pyx":633 * 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: # <<<<<<<<<<<<<< @@ -8662,7 +7582,7 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_4 = ((__pyx_v_money_amount < 0.0) != 0); if (__pyx_t_4) { - /* "trade.pyx":541 + /* "trade.pyx":634 * 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 # <<<<<<<<<<<<<< @@ -8671,7 +7591,7 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self */ __pyx_v_money_amount = 0.0; - /* "trade.pyx":540 + /* "trade.pyx":633 * 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: # <<<<<<<<<<<<<< @@ -8680,7 +7600,7 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self */ } - /* "trade.pyx":542 + /* "trade.pyx":635 * if money_amount < 0: * money_amount = 0 * if money_amount > available: # <<<<<<<<<<<<<< @@ -8690,7 +7610,7 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_4 = ((__pyx_v_money_amount > __pyx_v_available) != 0); if (__pyx_t_4) { - /* "trade.pyx":543 + /* "trade.pyx":636 * money_amount = 0 * if money_amount > available: * money_amount = available # <<<<<<<<<<<<<< @@ -8699,7 +7619,7 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self */ __pyx_v_money_amount = __pyx_v_available; - /* "trade.pyx":542 + /* "trade.pyx":635 * if money_amount < 0: * money_amount = 0 * if money_amount > available: # <<<<<<<<<<<<<< @@ -8708,14 +7628,14 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self */ } - /* "trade.pyx":545 + /* "trade.pyx":638 * money_amount = available * * offer_id = self._offer_counter() # <<<<<<<<<<<<<< * self._inventory.reserve(currency, money_amount) * cdef Offer offer = Offer(self.name, */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_offer_counter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 545, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_offer_counter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 638, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { @@ -8728,29 +7648,29 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self } } if (__pyx_t_3) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 545, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 638, __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, 545, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 638, __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":546 + /* "trade.pyx":639 * * offer_id = self._offer_counter() * self._inventory.reserve(currency, money_amount) # <<<<<<<<<<<<<< * cdef Offer offer = Offer(self.name, * receiver, */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 546, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 639, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_reserve); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 546, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_reserve); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 639, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_money_amount); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 546, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_money_amount); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 639, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = NULL; __pyx_t_7 = 0; @@ -8767,7 +7687,7 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self #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, 546, __pyx_L1_error) + __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, 639, __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; @@ -8776,14 +7696,14 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self #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, 546, __pyx_L1_error) + __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, 639, __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, 546, __pyx_L1_error) + __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 639, __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; @@ -8794,61 +7714,61 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self __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, 546, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 639, __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":547 + /* "trade.pyx":640 * offer_id = self._offer_counter() * self._inventory.reserve(currency, money_amount) * cdef Offer offer = Offer(self.name, # <<<<<<<<<<<<<< * receiver, * good, */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 547, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 640, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - /* "trade.pyx":550 + /* "trade.pyx":643 * receiver, * good, * quantity, # <<<<<<<<<<<<<< * price, * currency, */ - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 550, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 643, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - /* "trade.pyx":551 + /* "trade.pyx":644 * good, * quantity, * price, # <<<<<<<<<<<<<< * currency, * False, */ - __pyx_t_8 = PyFloat_FromDouble(__pyx_v_price); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 551, __pyx_L1_error) + __pyx_t_8 = PyFloat_FromDouble(__pyx_v_price); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 644, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - /* "trade.pyx":557 + /* "trade.pyx":650 * -1, * offer_id, * self.time, # <<<<<<<<<<<<<< * -1) * self._send(receiver, 'abce_propose_buy', offer) */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_time); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 557, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_time); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 650, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - /* "trade.pyx":547 + /* "trade.pyx":640 * offer_id = self._offer_counter() * self._inventory.reserve(currency, money_amount) * cdef Offer offer = Offer(self.name, # <<<<<<<<<<<<<< * receiver, * good, */ - __pyx_t_6 = PyTuple_New(12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 547, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 640, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); @@ -8886,20 +7806,20 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self __pyx_t_3 = 0; __pyx_t_8 = 0; __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5trade_Offer), __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 547, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5trade_Offer), __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 640, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_offer = ((struct __pyx_obj_5trade_Offer *)__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":559 + /* "trade.pyx":652 * self.time, * -1) * self._send(receiver, 'abce_propose_buy', offer) # <<<<<<<<<<<<<< * self.given_offers[offer_id] = offer * return offer */ - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_send); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 559, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_send); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = NULL; __pyx_t_7 = 0; @@ -8916,7 +7836,7 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_v_receiver, __pyx_n_s_abce_propose_buy, ((PyObject *)__pyx_v_offer)}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 559, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 652, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_1); } else @@ -8924,13 +7844,13 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_v_receiver, __pyx_n_s_abce_propose_buy, ((PyObject *)__pyx_v_offer)}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 559, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 652, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { - __pyx_t_3 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 559, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8); __pyx_t_8 = NULL; @@ -8944,26 +7864,26 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self __Pyx_INCREF(((PyObject *)__pyx_v_offer)); __Pyx_GIVEREF(((PyObject *)__pyx_v_offer)); PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_7, ((PyObject *)__pyx_v_offer)); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 559, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":560 + /* "trade.pyx":653 * -1) * self._send(receiver, 'abce_propose_buy', offer) * self.given_offers[offer_id] = offer # <<<<<<<<<<<<<< * return offer * */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_given_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 560, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_given_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 653, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_offer_id, ((PyObject *)__pyx_v_offer)) < 0)) __PYX_ERR(0, 560, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_offer_id, ((PyObject *)__pyx_v_offer)) < 0)) __PYX_ERR(0, 653, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":561 + /* "trade.pyx":654 * self._send(receiver, 'abce_propose_buy', offer) * self.given_offers[offer_id] = offer * return offer # <<<<<<<<<<<<<< @@ -8975,10 +7895,10 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self __pyx_r = ((PyObject *)__pyx_v_offer); goto __pyx_L0; - /* "trade.pyx":499 + /* "trade.pyx":592 * return offer * - * def buy(self, receiver, good, # <<<<<<<<<<<<<< + * def make_bid(self, receiver, good, # <<<<<<<<<<<<<< * double quantity, double price, str currency='money', double epsilon=epsilon): * """ commits to sell the quantity of good at price */ @@ -8990,7 +7910,7 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("trade.Trade.buy", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("trade.Trade.make_bid", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_offer_id); @@ -9000,12 +7920,12 @@ static PyObject *__pyx_pf_5trade_5Trade_26buy(CYTHON_UNUSED PyObject *__pyx_self return __pyx_r; } -/* "trade.pyx":563 +/* "trade.pyx":656 * 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 + * """ The offer or bid is accepted and cleared. If no quantity is + * given the offer/bid is fully accepted; If a quantity is given the offer/bid is */ static PyObject *__pyx_pf_5trade_8__defaults__(CYTHON_UNUSED PyObject *__pyx_self) { @@ -9016,11 +7936,11 @@ static PyObject *__pyx_pf_5trade_8__defaults__(CYTHON_UNUSED PyObject *__pyx_sel PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("__defaults__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(((double)-999.0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 563, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(((double)-999.0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyFloat_FromDouble(__Pyx_CyFunction_Defaults(__pyx_defaults2, __pyx_self)->__pyx_arg_epsilon); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 563, __pyx_L1_error) + __pyx_t_2 = PyFloat_FromDouble(__Pyx_CyFunction_Defaults(__pyx_defaults2, __pyx_self)->__pyx_arg_epsilon); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 563, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); @@ -9028,7 +7948,7 @@ static PyObject *__pyx_pf_5trade_8__defaults__(CYTHON_UNUSED PyObject *__pyx_sel PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 563, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); @@ -9054,10 +7974,10 @@ static PyObject *__pyx_pf_5trade_8__defaults__(CYTHON_UNUSED PyObject *__pyx_sel } /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_29accept(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_5trade_5Trade_28accept[] = " The buy or sell offer is accepted and cleared. If no quantity is\n given the offer is fully accepted; If a quantity is given the offer is\n partial accepted.\n\n Args:\n\n offer:\n the offer the other party made\n quantity:\n quantity to accept. If not given all is accepted\n\n epsilon (optional):\n if you have floating point errors, a quantity or prices is\n a fraction of number to high or low. You can increase the\n floating point tolerance. See troubleshooting -- floating point problems\n\n Return:\n Returns a dictionary with the good's quantity and the amount paid.\n "; -static PyMethodDef __pyx_mdef_5trade_5Trade_29accept = {"accept", (PyCFunction)__pyx_pw_5trade_5Trade_29accept, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_28accept}; -static PyObject *__pyx_pw_5trade_5Trade_29accept(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5trade_5Trade_23accept(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5trade_5Trade_22accept[] = " The offer or bid is accepted and cleared. If no quantity is\n given the offer/bid is fully accepted; If a quantity is given the offer/bid is\n partial accepted.\n\n Args:\n\n offer:\n the offer the other party made\n quantity:\n quantity to accept. If not given all is accepted\n\n epsilon (optional):\n if you have floating point errors, a quantity or prices is\n a fraction of number to high or low. You can increase the\n floating point tolerance. See troubleshooting -- floating point problems\n\n Return:\n Returns a dictionary with the good's quantity and the amount paid.\n "; +static PyMethodDef __pyx_mdef_5trade_5Trade_23accept = {"accept", (PyCFunction)__pyx_pw_5trade_5Trade_23accept, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_22accept}; +static PyObject *__pyx_pw_5trade_5Trade_23accept(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; struct __pyx_obj_5trade_Offer *__pyx_v_offer = 0; double __pyx_v_quantity; @@ -9093,7 +8013,7 @@ static PyObject *__pyx_pw_5trade_5Trade_29accept(PyObject *__pyx_self, PyObject case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_offer)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("accept", 0, 2, 4, 1); __PYX_ERR(0, 563, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("accept", 0, 2, 4, 1); __PYX_ERR(0, 656, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: @@ -9109,7 +8029,7 @@ static PyObject *__pyx_pw_5trade_5Trade_29accept(PyObject *__pyx_self, PyObject } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "accept") < 0)) __PYX_ERR(0, 563, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "accept") < 0)) __PYX_ERR(0, 656, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -9126,26 +8046,26 @@ static PyObject *__pyx_pw_5trade_5Trade_29accept(PyObject *__pyx_self, PyObject __pyx_v_self = values[0]; __pyx_v_offer = ((struct __pyx_obj_5trade_Offer *)values[1]); if (values[2]) { - __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 563, __pyx_L3_error) + __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 656, __pyx_L3_error) } else { __pyx_v_quantity = ((double)((double)-999.0)); } if (values[3]) { - __pyx_v_epsilon = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_epsilon == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 563, __pyx_L3_error) + __pyx_v_epsilon = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_epsilon == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 656, __pyx_L3_error) } else { __pyx_v_epsilon = __pyx_dynamic_args->__pyx_arg_epsilon; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("accept", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 563, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("accept", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 656, __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, 563, __pyx_L1_error) - __pyx_r = __pyx_pf_5trade_5Trade_28accept(__pyx_self, __pyx_v_self, __pyx_v_offer, __pyx_v_quantity, __pyx_v_epsilon); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_offer), __pyx_ptype_5trade_Offer, 1, "offer", 0))) __PYX_ERR(0, 656, __pyx_L1_error) + __pyx_r = __pyx_pf_5trade_5Trade_22accept(__pyx_self, __pyx_v_self, __pyx_v_offer, __pyx_v_quantity, __pyx_v_epsilon); /* function exit code */ goto __pyx_L0; @@ -9156,7 +8076,7 @@ static PyObject *__pyx_pw_5trade_5Trade_29accept(PyObject *__pyx_self, PyObject return __pyx_r; } -static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, struct __pyx_obj_5trade_Offer *__pyx_v_offer, double __pyx_v_quantity, double __pyx_v_epsilon) { +static PyObject *__pyx_pf_5trade_5Trade_22accept(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, struct __pyx_obj_5trade_Offer *__pyx_v_offer, double __pyx_v_quantity, double __pyx_v_epsilon) { double __pyx_v_money_amount; double __pyx_v_offer_quantity; double __pyx_v_available; @@ -9176,7 +8096,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s PyObject *__pyx_t_12 = NULL; __Pyx_RefNannySetupContext("accept", 0); - /* "trade.pyx":584 + /* "trade.pyx":677 * """ * cdef double money_amount * cdef double offer_quantity = offer.quantity # <<<<<<<<<<<<<< @@ -9186,7 +8106,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s __pyx_t_1 = __pyx_v_offer->quantity; __pyx_v_offer_quantity = __pyx_t_1; - /* "trade.pyx":587 + /* "trade.pyx":680 * cdef double available * * if quantity == -999: # <<<<<<<<<<<<<< @@ -9196,7 +8116,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s __pyx_t_2 = ((__pyx_v_quantity == -999.0) != 0); if (__pyx_t_2) { - /* "trade.pyx":588 + /* "trade.pyx":681 * * if quantity == -999: * quantity = offer_quantity # <<<<<<<<<<<<<< @@ -9205,7 +8125,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ __pyx_v_quantity = __pyx_v_offer_quantity; - /* "trade.pyx":587 + /* "trade.pyx":680 * cdef double available * * if quantity == -999: # <<<<<<<<<<<<<< @@ -9214,7 +8134,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ } - /* "trade.pyx":589 + /* "trade.pyx":682 * if quantity == -999: * quantity = offer_quantity * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) # <<<<<<<<<<<<<< @@ -9224,11 +8144,11 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s #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, 589, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 682, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 589, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 682, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 589, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 682, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); @@ -9236,17 +8156,17 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s 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, 589, __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, 682, __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, 589, __pyx_L1_error) + __PYX_ERR(0, 682, __pyx_L1_error) } } #endif - /* "trade.pyx":590 + /* "trade.pyx":683 * quantity = offer_quantity * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: # <<<<<<<<<<<<<< @@ -9256,7 +8176,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s __pyx_t_2 = ((__pyx_v_quantity < 0.0) != 0); if (__pyx_t_2) { - /* "trade.pyx":591 + /* "trade.pyx":684 * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: * quantity = 0 # <<<<<<<<<<<<<< @@ -9265,7 +8185,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ __pyx_v_quantity = 0.0; - /* "trade.pyx":590 + /* "trade.pyx":683 * quantity = offer_quantity * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: # <<<<<<<<<<<<<< @@ -9274,7 +8194,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ } - /* "trade.pyx":592 + /* "trade.pyx":685 * if quantity < 0: * quantity = 0 * if quantity > offer_quantity + epsilon * fmax(quantity, offer_quantity): # <<<<<<<<<<<<<< @@ -9284,18 +8204,18 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s __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 (unlikely(__pyx_t_2)) { - /* "trade.pyx":594 + /* "trade.pyx":687 * 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, 594, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 687, __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, 594, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_offer_quantity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 687, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 594, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 687, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_offer->good); __Pyx_GIVEREF(__pyx_v_offer->good); @@ -9306,25 +8226,25 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s 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, 594, __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, 687, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "trade.pyx":593 + /* "trade.pyx":686 * 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 = __Pyx_PyObject_CallOneArg(__pyx_builtin_AssertionError, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 593, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_AssertionError, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 686, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 593, __pyx_L1_error) + __PYX_ERR(0, 686, __pyx_L1_error) - /* "trade.pyx":592 + /* "trade.pyx":685 * if quantity < 0: * quantity = 0 * if quantity > offer_quantity + epsilon * fmax(quantity, offer_quantity): # <<<<<<<<<<<<<< @@ -9333,7 +8253,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ } - /* "trade.pyx":595 + /* "trade.pyx":688 * raise AssertionError('accepted more than offered %s: %.100f >= %.100f' * % (offer.good, quantity, offer_quantity)) * if quantity > offer_quantity: # <<<<<<<<<<<<<< @@ -9343,7 +8263,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s __pyx_t_2 = ((__pyx_v_quantity > __pyx_v_offer_quantity) != 0); if (__pyx_t_2) { - /* "trade.pyx":596 + /* "trade.pyx":689 * % (offer.good, quantity, offer_quantity)) * if quantity > offer_quantity: * quantity = offer_quantity # <<<<<<<<<<<<<< @@ -9352,7 +8272,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ __pyx_v_quantity = __pyx_v_offer_quantity; - /* "trade.pyx":595 + /* "trade.pyx":688 * raise AssertionError('accepted more than offered %s: %.100f >= %.100f' * % (offer.good, quantity, offer_quantity)) * if quantity > offer_quantity: # <<<<<<<<<<<<<< @@ -9361,7 +8281,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ } - /* "trade.pyx":598 + /* "trade.pyx":691 * quantity = offer_quantity * * if quantity == 0: # <<<<<<<<<<<<<< @@ -9371,14 +8291,14 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s __pyx_t_2 = ((__pyx_v_quantity == 0.0) != 0); if (__pyx_t_2) { - /* "trade.pyx":599 + /* "trade.pyx":692 * * if quantity == 0: * self.reject(offer) # <<<<<<<<<<<<<< * return {offer.good: 0, offer.currency: 0} * */ - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_reject); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 599, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_reject); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 692, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { @@ -9391,13 +8311,13 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s } } if (!__pyx_t_4) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_offer)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 599, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_offer)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 692, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_offer)}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 599, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 692, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_3); } else @@ -9405,19 +8325,19 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_offer)}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 599, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 692, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_3); } else #endif { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 599, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 692, __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_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 599, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 692, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } @@ -9425,7 +8345,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "trade.pyx":600 + /* "trade.pyx":693 * if quantity == 0: * self.reject(offer) * return {offer.good: 0, offer.currency: 0} # <<<<<<<<<<<<<< @@ -9433,15 +8353,15 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s * money_amount = quantity * offer.price */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 600, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 693, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_3, __pyx_v_offer->good, __pyx_int_0) < 0) __PYX_ERR(0, 600, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_3, __pyx_v_offer->currency, __pyx_int_0) < 0) __PYX_ERR(0, 600, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_v_offer->good, __pyx_int_0) < 0) __PYX_ERR(0, 693, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_v_offer->currency, __pyx_int_0) < 0) __PYX_ERR(0, 693, __pyx_L1_error) __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; - /* "trade.pyx":598 + /* "trade.pyx":691 * quantity = offer_quantity * * if quantity == 0: # <<<<<<<<<<<<<< @@ -9450,7 +8370,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ } - /* "trade.pyx":602 + /* "trade.pyx":695 * return {offer.good: 0, offer.currency: 0} * * money_amount = quantity * offer.price # <<<<<<<<<<<<<< @@ -9459,7 +8379,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ __pyx_v_money_amount = (__pyx_v_quantity * __pyx_v_offer->price); - /* "trade.pyx":603 + /* "trade.pyx":696 * * money_amount = quantity * offer.price * if offer.sell: # ord('s') # <<<<<<<<<<<<<< @@ -9469,7 +8389,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s __pyx_t_2 = (__pyx_v_offer->sell != 0); if (__pyx_t_2) { - /* "trade.pyx":604 + /* "trade.pyx":697 * 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) # <<<<<<<<<<<<<< @@ -9479,11 +8399,11 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s #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, 604, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_money_amount); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 697, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 604, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 697, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 604, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 697, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); @@ -9491,17 +8411,17 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5); __pyx_t_3 = 0; __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_money_quantity_offer_price_30f_i, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 604, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_money_quantity_offer_price_30f_i, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 697, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __PYX_ERR(0, 604, __pyx_L1_error) + __PYX_ERR(0, 697, __pyx_L1_error) } } #endif - /* "trade.pyx":605 + /* "trade.pyx":698 * 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: # <<<<<<<<<<<<<< @@ -9511,7 +8431,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s __pyx_t_2 = ((__pyx_v_money_amount < 0.0) != 0); if (__pyx_t_2) { - /* "trade.pyx":606 + /* "trade.pyx":699 * 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 # <<<<<<<<<<<<<< @@ -9520,7 +8440,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ __pyx_v_money_amount = 0.0; - /* "trade.pyx":605 + /* "trade.pyx":698 * 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: # <<<<<<<<<<<<<< @@ -9529,23 +8449,23 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ } - /* "trade.pyx":608 + /* "trade.pyx":701 * money_amount = 0 * * 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_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 608, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyObject_Dict_GetItem(__pyx_t_5, __pyx_v_offer->currency); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 608, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_Dict_GetItem(__pyx_t_5, __pyx_v_offer->currency); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 608, __pyx_L1_error) + __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 701, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_available = __pyx_t_1; - /* "trade.pyx":609 + /* "trade.pyx":702 * * available = self._inventory[offer.currency] * if money_amount > available + epsilon + epsilon * max(money_amount, available): # <<<<<<<<<<<<<< @@ -9562,18 +8482,18 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s __pyx_t_2 = ((__pyx_v_money_amount > ((__pyx_v_available + __pyx_v_epsilon) + (__pyx_v_epsilon * __pyx_t_8))) != 0); if (unlikely(__pyx_t_2)) { - /* "trade.pyx":610 + /* "trade.pyx":703 * 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_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_NotEnoughGoods); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 610, __pyx_L1_error) + __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_NotEnoughGoods); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 610, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyFloat_FromDouble((__pyx_v_money_amount - __pyx_v_available)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 610, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble((__pyx_v_money_amount - __pyx_v_available)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = NULL; __pyx_t_10 = 0; @@ -9590,7 +8510,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_3, __pyx_v_offer->currency, __pyx_t_4}; - __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 610, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 703, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -9600,7 +8520,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_3, __pyx_v_offer->currency, __pyx_t_4}; - __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 610, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 703, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -9608,7 +8528,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s } else #endif { - __pyx_t_11 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 610, __pyx_L1_error) + __pyx_t_11 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 703, __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; @@ -9622,16 +8542,16 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_t_4); __pyx_t_3 = 0; __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 610, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __PYX_ERR(0, 610, __pyx_L1_error) + __PYX_ERR(0, 703, __pyx_L1_error) - /* "trade.pyx":609 + /* "trade.pyx":702 * * available = self._inventory[offer.currency] * if money_amount > available + epsilon + epsilon * max(money_amount, available): # <<<<<<<<<<<<<< @@ -9640,7 +8560,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ } - /* "trade.pyx":611 + /* "trade.pyx":704 * if money_amount > available + epsilon + epsilon * max(money_amount, available): * raise NotEnoughGoods(self.name, offer.currency, money_amount - available) * if money_amount > available: # <<<<<<<<<<<<<< @@ -9650,7 +8570,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s __pyx_t_2 = ((__pyx_v_money_amount > __pyx_v_available) != 0); if (__pyx_t_2) { - /* "trade.pyx":612 + /* "trade.pyx":705 * raise NotEnoughGoods(self.name, offer.currency, money_amount - available) * if money_amount > available: * money_amount = available # <<<<<<<<<<<<<< @@ -9659,7 +8579,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ __pyx_v_money_amount = __pyx_v_available; - /* "trade.pyx":611 + /* "trade.pyx":704 * if money_amount > available + epsilon + epsilon * max(money_amount, available): * raise NotEnoughGoods(self.name, offer.currency, money_amount - available) * if money_amount > available: # <<<<<<<<<<<<<< @@ -9668,61 +8588,61 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ } - /* "trade.pyx":613 + /* "trade.pyx":706 * if money_amount > available: * money_amount = available * self._inventory.haves[offer.good] += quantity # <<<<<<<<<<<<<< * self._inventory.haves[offer.currency] -= quantity * offer.price * else: */ - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 613, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_haves); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 613, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_haves); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_INCREF(__pyx_v_offer->good); __pyx_t_6 = __pyx_v_offer->good; - __pyx_t_11 = __Pyx_PyObject_GetItem(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 613, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetItem(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_4 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 613, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_11, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 613, __pyx_L1_error) + __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_11, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_t_6, __pyx_t_3) < 0)) __PYX_ERR(0, 613, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_5, __pyx_t_6, __pyx_t_3) < 0)) __PYX_ERR(0, 706, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - /* "trade.pyx":614 + /* "trade.pyx":707 * money_amount = available * 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_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 614, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 707, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_haves); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 614, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_haves); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 707, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_v_offer->currency); __pyx_t_12 = __pyx_v_offer->currency; - __pyx_t_5 = __Pyx_PyObject_Dict_GetItem(__pyx_t_6, __pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 614, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Dict_GetItem(__pyx_t_6, __pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 707, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyFloat_FromDouble((__pyx_v_quantity * __pyx_v_offer->price)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 614, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble((__pyx_v_quantity * __pyx_v_offer->price)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 707, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyNumber_InPlaceSubtract(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 614, __pyx_L1_error) + __pyx_t_4 = PyNumber_InPlaceSubtract(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 707, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_6, __pyx_t_12, __pyx_t_4) < 0)) __PYX_ERR(0, 614, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_6, __pyx_t_12, __pyx_t_4) < 0)) __PYX_ERR(0, 707, __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":603 + /* "trade.pyx":696 * * money_amount = quantity * offer.price * if offer.sell: # ord('s') # <<<<<<<<<<<<<< @@ -9732,7 +8652,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s goto __pyx_L8; } - /* "trade.pyx":616 + /* "trade.pyx":709 * self._inventory.haves[offer.currency] -= quantity * offer.price * else: * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) # <<<<<<<<<<<<<< @@ -9743,11 +8663,11 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s #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, 616, __pyx_L1_error) + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 709, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 616, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 709, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 616, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 709, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); @@ -9755,17 +8675,17 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s PyTuple_SET_ITEM(__pyx_t_3, 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_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 616, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_quantity_30f_is_smaller_than_0_e, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 709, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(0, 616, __pyx_L1_error) + __PYX_ERR(0, 709, __pyx_L1_error) } } #endif - /* "trade.pyx":617 + /* "trade.pyx":710 * else: * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: # <<<<<<<<<<<<<< @@ -9775,7 +8695,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s __pyx_t_2 = ((__pyx_v_quantity < 0.0) != 0); if (__pyx_t_2) { - /* "trade.pyx":618 + /* "trade.pyx":711 * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: * quantity = 0 # <<<<<<<<<<<<<< @@ -9784,7 +8704,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ __pyx_v_quantity = 0.0; - /* "trade.pyx":617 + /* "trade.pyx":710 * else: * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: # <<<<<<<<<<<<<< @@ -9793,23 +8713,23 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ } - /* "trade.pyx":619 + /* "trade.pyx":712 * if quantity < 0: * quantity = 0 * 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(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 619, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 712, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_4, __pyx_v_offer->good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 619, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_4, __pyx_v_offer->good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 712, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 619, __pyx_L1_error) + __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 712, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_available = __pyx_t_8; - /* "trade.pyx":620 + /* "trade.pyx":713 * quantity = 0 * available = self._inventory[offer.good] * if quantity > available + epsilon + epsilon * max(quantity, available): # <<<<<<<<<<<<<< @@ -9826,18 +8746,18 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s __pyx_t_2 = ((__pyx_v_quantity > ((__pyx_v_available + __pyx_v_epsilon) + (__pyx_v_epsilon * __pyx_t_7))) != 0); if (unlikely(__pyx_t_2)) { - /* "trade.pyx":621 + /* "trade.pyx":714 * 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, 621, __pyx_L1_error) + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_NotEnoughGoods); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 714, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 621, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 714, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = PyFloat_FromDouble((__pyx_v_quantity - __pyx_v_available)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 621, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble((__pyx_v_quantity - __pyx_v_available)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 714, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_11 = NULL; __pyx_t_10 = 0; @@ -9854,7 +8774,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s #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_5}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 621, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 714, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -9864,7 +8784,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s #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_5}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 621, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 714, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -9872,7 +8792,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s } else #endif { - __pyx_t_9 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 621, __pyx_L1_error) + __pyx_t_9 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 714, __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; @@ -9886,16 +8806,16 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_10, __pyx_t_5); __pyx_t_6 = 0; __pyx_t_5 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 621, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 714, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 621, __pyx_L1_error) + __PYX_ERR(0, 714, __pyx_L1_error) - /* "trade.pyx":620 + /* "trade.pyx":713 * quantity = 0 * available = self._inventory[offer.good] * if quantity > available + epsilon + epsilon * max(quantity, available): # <<<<<<<<<<<<<< @@ -9904,7 +8824,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ } - /* "trade.pyx":622 + /* "trade.pyx":715 * if quantity > available + epsilon + epsilon * max(quantity, available): * raise NotEnoughGoods(self.name, offer.good, quantity - available) * if quantity > available: # <<<<<<<<<<<<<< @@ -9914,7 +8834,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s __pyx_t_2 = ((__pyx_v_quantity > __pyx_v_available) != 0); if (__pyx_t_2) { - /* "trade.pyx":623 + /* "trade.pyx":716 * raise NotEnoughGoods(self.name, offer.good, quantity - available) * if quantity > available: * quantity = available # <<<<<<<<<<<<<< @@ -9923,7 +8843,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ __pyx_v_quantity = __pyx_v_available; - /* "trade.pyx":622 + /* "trade.pyx":715 * if quantity > available + epsilon + epsilon * max(quantity, available): * raise NotEnoughGoods(self.name, offer.good, quantity - available) * if quantity > available: # <<<<<<<<<<<<<< @@ -9932,63 +8852,63 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ } - /* "trade.pyx":624 + /* "trade.pyx":717 * if quantity > available: * quantity = available * self._inventory.haves[offer.good] -= quantity # <<<<<<<<<<<<<< * self._inventory.haves[offer.currency] += quantity * offer.price * offer.final_quantity = quantity */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 624, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 717, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_haves); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 624, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_haves); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 717, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_v_offer->good); __pyx_t_3 = __pyx_v_offer->good; - __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 624, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 717, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_5 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 624, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 717, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyNumber_InPlaceSubtract(__pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 624, __pyx_L1_error) + __pyx_t_6 = PyNumber_InPlaceSubtract(__pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 717, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_4, __pyx_t_3, __pyx_t_6) < 0)) __PYX_ERR(0, 624, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_4, __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_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "trade.pyx":625 + /* "trade.pyx":718 * quantity = available * self._inventory.haves[offer.good] -= quantity * self._inventory.haves[offer.currency] += quantity * offer.price # <<<<<<<<<<<<<< * offer.final_quantity = quantity * self._send(offer.sender, 'abce_receive_accept', (offer.id, quantity)) */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 625, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 718, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_haves); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 625, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_haves); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 718, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __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 = __Pyx_PyObject_Dict_GetItem(__pyx_t_3, __pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 625, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Dict_GetItem(__pyx_t_3, __pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 718, __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, 625, __pyx_L1_error) + __pyx_t_6 = PyFloat_FromDouble((__pyx_v_quantity * __pyx_v_offer->price)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 718, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 625, __pyx_L1_error) + __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 718, __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; - if (unlikely(PyObject_SetItem(__pyx_t_3, __pyx_t_12, __pyx_t_5) < 0)) __PYX_ERR(0, 625, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_3, __pyx_t_12, __pyx_t_5) < 0)) __PYX_ERR(0, 718, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_L8:; - /* "trade.pyx":626 + /* "trade.pyx":719 * self._inventory.haves[offer.good] -= quantity * self._inventory.haves[offer.currency] += quantity * offer.price * offer.final_quantity = quantity # <<<<<<<<<<<<<< @@ -9997,18 +8917,18 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ __pyx_v_offer->final_quantity = __pyx_v_quantity; - /* "trade.pyx":627 + /* "trade.pyx":720 * self._inventory.haves[offer.currency] += quantity * offer.price * offer.final_quantity = quantity * self._send(offer.sender, 'abce_receive_accept', (offer.id, quantity)) # <<<<<<<<<<<<<< * del self._polled_offers[offer.id] * if offer.sell: # ord('s') */ - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_send); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 627, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_send); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 627, __pyx_L1_error) + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 627, __pyx_L1_error) + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_offer->id); __Pyx_GIVEREF(__pyx_v_offer->id); @@ -10031,7 +8951,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_v_offer->sender, __pyx_n_s_abce_receive_accept, __pyx_t_4}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 627, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 720, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -10040,14 +8960,14 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_v_offer->sender, __pyx_n_s_abce_receive_accept, __pyx_t_4}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 627, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 720, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { - __pyx_t_9 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 627, __pyx_L1_error) + __pyx_t_9 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL; @@ -10061,26 +8981,26 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_10, __pyx_t_4); __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 627, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "trade.pyx":628 + /* "trade.pyx":721 * offer.final_quantity = quantity * self._send(offer.sender, 'abce_receive_accept', (offer.id, quantity)) * del self._polled_offers[offer.id] # <<<<<<<<<<<<<< * if offer.sell: # ord('s') * return {offer.good: - quantity, offer.currency: money_amount} */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_polled_offers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 628, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_polled_offers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 721, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (unlikely(PyObject_DelItem(__pyx_t_3, __pyx_v_offer->id) < 0)) __PYX_ERR(0, 628, __pyx_L1_error) + if (unlikely(PyObject_DelItem(__pyx_t_3, __pyx_v_offer->id) < 0)) __PYX_ERR(0, 721, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "trade.pyx":629 + /* "trade.pyx":722 * self._send(offer.sender, 'abce_receive_accept', (offer.id, quantity)) * del self._polled_offers[offer.id] * if offer.sell: # ord('s') # <<<<<<<<<<<<<< @@ -10090,7 +9010,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s __pyx_t_2 = (__pyx_v_offer->sell != 0); if (__pyx_t_2) { - /* "trade.pyx":630 + /* "trade.pyx":723 * del self._polled_offers[offer.id] * if offer.sell: # ord('s') * return {offer.good: - quantity, offer.currency: money_amount} # <<<<<<<<<<<<<< @@ -10098,21 +9018,21 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s * return {offer.good: quantity, offer.currency: - money_amount} */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 630, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyFloat_FromDouble((-__pyx_v_quantity)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 630, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble((-__pyx_v_quantity)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - if (PyDict_SetItem(__pyx_t_3, __pyx_v_offer->good, __pyx_t_5) < 0) __PYX_ERR(0, 630, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_v_offer->good, __pyx_t_5) < 0) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyFloat_FromDouble(__pyx_v_money_amount); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 630, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_money_amount); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - if (PyDict_SetItem(__pyx_t_3, __pyx_v_offer->currency, __pyx_t_5) < 0) __PYX_ERR(0, 630, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_v_offer->currency, __pyx_t_5) < 0) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; - /* "trade.pyx":629 + /* "trade.pyx":722 * self._send(offer.sender, 'abce_receive_accept', (offer.id, quantity)) * del self._polled_offers[offer.id] * if offer.sell: # ord('s') # <<<<<<<<<<<<<< @@ -10121,7 +9041,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ } - /* "trade.pyx":632 + /* "trade.pyx":725 * return {offer.good: - quantity, offer.currency: money_amount} * else: * return {offer.good: quantity, offer.currency: - money_amount} # <<<<<<<<<<<<<< @@ -10130,27 +9050,27 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ /*else*/ { __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 632, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 725, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 632, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 725, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - if (PyDict_SetItem(__pyx_t_3, __pyx_v_offer->good, __pyx_t_5) < 0) __PYX_ERR(0, 632, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_v_offer->good, __pyx_t_5) < 0) __PYX_ERR(0, 725, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyFloat_FromDouble((-__pyx_v_money_amount)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 632, __pyx_L1_error) + __pyx_t_5 = PyFloat_FromDouble((-__pyx_v_money_amount)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 725, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - if (PyDict_SetItem(__pyx_t_3, __pyx_v_offer->currency, __pyx_t_5) < 0) __PYX_ERR(0, 632, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_v_offer->currency, __pyx_t_5) < 0) __PYX_ERR(0, 725, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; } - /* "trade.pyx":563 + /* "trade.pyx":656 * 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 + * """ The offer or bid is accepted and cleared. If no quantity is + * given the offer/bid is fully accepted; If a quantity is given the offer/bid is */ /* function exit code */ @@ -10170,7 +9090,7 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s return __pyx_r; } -/* "trade.pyx":634 +/* "trade.pyx":727 * return {offer.good: quantity, offer.currency: - money_amount} * * def _reject_polled_but_not_accepted_offers(self): # <<<<<<<<<<<<<< @@ -10179,20 +9099,20 @@ static PyObject *__pyx_pf_5trade_5Trade_28accept(CYTHON_UNUSED PyObject *__pyx_s */ /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_31_reject_polled_but_not_accepted_offers(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/ -static PyMethodDef __pyx_mdef_5trade_5Trade_31_reject_polled_but_not_accepted_offers = {"_reject_polled_but_not_accepted_offers", (PyCFunction)__pyx_pw_5trade_5Trade_31_reject_polled_but_not_accepted_offers, METH_O, 0}; -static PyObject *__pyx_pw_5trade_5Trade_31_reject_polled_but_not_accepted_offers(PyObject *__pyx_self, PyObject *__pyx_v_self) { +static PyObject *__pyx_pw_5trade_5Trade_25_reject_polled_but_not_accepted_offers(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/ +static PyMethodDef __pyx_mdef_5trade_5Trade_25_reject_polled_but_not_accepted_offers = {"_reject_polled_but_not_accepted_offers", (PyCFunction)__pyx_pw_5trade_5Trade_25_reject_polled_but_not_accepted_offers, METH_O, 0}; +static PyObject *__pyx_pw_5trade_5Trade_25_reject_polled_but_not_accepted_offers(PyObject *__pyx_self, PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_reject_polled_but_not_accepted_offers (wrapper)", 0); - __pyx_r = __pyx_pf_5trade_5Trade_30_reject_polled_but_not_accepted_offers(__pyx_self, ((PyObject *)__pyx_v_self)); + __pyx_r = __pyx_pf_5trade_5Trade_24_reject_polled_but_not_accepted_offers(__pyx_self, ((PyObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_5trade_5Trade_30_reject_polled_but_not_accepted_offers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) { +static PyObject *__pyx_pf_5trade_5Trade_24_reject_polled_but_not_accepted_offers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) { struct __pyx_obj_5trade_Offer *__pyx_v_offer = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -10205,16 +9125,16 @@ static PyObject *__pyx_pf_5trade_5Trade_30_reject_polled_but_not_accepted_offers PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("_reject_polled_but_not_accepted_offers", 0); - /* "trade.pyx":636 + /* "trade.pyx":729 * 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(__pyx_v_self, __pyx_n_s_polled_offers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 636, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_polled_offers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 729, __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, 636, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_values); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; @@ -10228,10 +9148,10 @@ static PyObject *__pyx_pf_5trade_5Trade_30_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, 636, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 729, __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, 636, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 729, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -10239,9 +9159,9 @@ static PyObject *__pyx_pf_5trade_5Trade_30_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, 636, __pyx_L1_error) + __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 729, __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, 636, __pyx_L1_error) + __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 729, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { @@ -10249,17 +9169,17 @@ static PyObject *__pyx_pf_5trade_5Trade_30_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, 636, __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, 729, __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, 636, __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, 729, __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, 636, __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, 729, __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, 636, __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, 729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } @@ -10269,24 +9189,24 @@ static PyObject *__pyx_pf_5trade_5Trade_30_reject_polled_but_not_accepted_offers PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 636, __pyx_L1_error) + else __PYX_ERR(0, 729, __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, 636, __pyx_L1_error) + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5trade_Offer))))) __PYX_ERR(0, 729, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_offer, ((struct __pyx_obj_5trade_Offer *)__pyx_t_1)); __pyx_t_1 = 0; - /* "trade.pyx":637 + /* "trade.pyx":730 * cdef Offer offer * for offer in self._polled_offers.values(): * self._reject(offer) # <<<<<<<<<<<<<< * self._polled_offers = {} * */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_reject_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 637, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_reject_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { @@ -10299,13 +9219,13 @@ static PyObject *__pyx_pf_5trade_5Trade_30_reject_polled_but_not_accepted_offers } } if (!__pyx_t_6) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_offer)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 637, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_offer)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_6, ((PyObject *)__pyx_v_offer)}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 637, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 730, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); } else @@ -10313,19 +9233,19 @@ static PyObject *__pyx_pf_5trade_5Trade_30_reject_polled_but_not_accepted_offers #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[2] = {__pyx_t_6, ((PyObject *)__pyx_v_offer)}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 637, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 730, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { - __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 637, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 730, __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_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 637, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } @@ -10333,7 +9253,7 @@ static PyObject *__pyx_pf_5trade_5Trade_30_reject_polled_but_not_accepted_offers __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":636 + /* "trade.pyx":729 * def _reject_polled_but_not_accepted_offers(self): * cdef Offer offer * for offer in self._polled_offers.values(): # <<<<<<<<<<<<<< @@ -10343,19 +9263,19 @@ static PyObject *__pyx_pf_5trade_5Trade_30_reject_polled_but_not_accepted_offers } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "trade.pyx":638 + /* "trade.pyx":731 * for offer in self._polled_offers.values(): * self._reject(offer) * self._polled_offers = {} # <<<<<<<<<<<<<< * * def _reject(self, offer): */ - __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 638, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 731, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_polled_offers, __pyx_t_3) < 0) __PYX_ERR(0, 638, __pyx_L1_error) + if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_polled_offers, __pyx_t_3) < 0) __PYX_ERR(0, 731, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "trade.pyx":634 + /* "trade.pyx":727 * return {offer.good: quantity, offer.currency: - money_amount} * * def _reject_polled_but_not_accepted_offers(self): # <<<<<<<<<<<<<< @@ -10381,7 +9301,7 @@ static PyObject *__pyx_pf_5trade_5Trade_30_reject_polled_but_not_accepted_offers return __pyx_r; } -/* "trade.pyx":640 +/* "trade.pyx":733 * self._polled_offers = {} * * def _reject(self, offer): # <<<<<<<<<<<<<< @@ -10390,10 +9310,10 @@ static PyObject *__pyx_pf_5trade_5Trade_30_reject_polled_but_not_accepted_offers */ /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_33_reject(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_5trade_5Trade_32_reject[] = " Rejects the offer offer\n\n Args:\n offer:\n the offer the other party made\n (offer not quote!)\n "; -static PyMethodDef __pyx_mdef_5trade_5Trade_33_reject = {"_reject", (PyCFunction)__pyx_pw_5trade_5Trade_33_reject, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_32_reject}; -static PyObject *__pyx_pw_5trade_5Trade_33_reject(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5trade_5Trade_27_reject(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5trade_5Trade_26_reject[] = " Rejects the offer offer\n\n Args:\n offer:\n the offer the other party made\n (offer not quote!)\n "; +static PyMethodDef __pyx_mdef_5trade_5Trade_27_reject = {"_reject", (PyCFunction)__pyx_pw_5trade_5Trade_27_reject, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_26_reject}; +static PyObject *__pyx_pw_5trade_5Trade_27_reject(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_offer = 0; PyObject *__pyx_r = 0; @@ -10422,11 +9342,11 @@ static PyObject *__pyx_pw_5trade_5Trade_33_reject(PyObject *__pyx_self, PyObject case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_offer)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_reject", 1, 2, 2, 1); __PYX_ERR(0, 640, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("_reject", 1, 2, 2, 1); __PYX_ERR(0, 733, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_reject") < 0)) __PYX_ERR(0, 640, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_reject") < 0)) __PYX_ERR(0, 733, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -10439,20 +9359,20 @@ static PyObject *__pyx_pw_5trade_5Trade_33_reject(PyObject *__pyx_self, PyObject } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_reject", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 640, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("_reject", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 733, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade._reject", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5trade_5Trade_32_reject(__pyx_self, __pyx_v_self, __pyx_v_offer); + __pyx_r = __pyx_pf_5trade_5Trade_26_reject(__pyx_self, __pyx_v_self, __pyx_v_offer); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_5trade_5Trade_32_reject(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer) { +static PyObject *__pyx_pf_5trade_5Trade_26_reject(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -10464,18 +9384,18 @@ static PyObject *__pyx_pf_5trade_5Trade_32_reject(CYTHON_UNUSED PyObject *__pyx_ PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("_reject", 0); - /* "trade.pyx":648 + /* "trade.pyx":741 * (offer not quote!) * """ * self._send(offer.sender, 'abce_receive_reject', offer.id) # <<<<<<<<<<<<<< * * def reject(self, Offer offer): */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_send); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 648, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_send); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 741, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_sender); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 648, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_sender); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 741, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 648, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 741, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; @@ -10492,7 +9412,7 @@ static PyObject *__pyx_pf_5trade_5Trade_32_reject(CYTHON_UNUSED PyObject *__pyx_ #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, __pyx_n_s_abce_receive_reject, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 648, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 741, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -10502,7 +9422,7 @@ static PyObject *__pyx_pf_5trade_5Trade_32_reject(CYTHON_UNUSED PyObject *__pyx_ #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_3, __pyx_n_s_abce_receive_reject, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 648, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 741, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -10510,7 +9430,7 @@ static PyObject *__pyx_pf_5trade_5Trade_32_reject(CYTHON_UNUSED PyObject *__pyx_ } else #endif { - __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 648, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 741, __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; @@ -10524,14 +9444,14 @@ static PyObject *__pyx_pf_5trade_5Trade_32_reject(CYTHON_UNUSED PyObject *__pyx_ PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_t_4); __pyx_t_3 = 0; __pyx_t_4 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 648, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 741, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":640 + /* "trade.pyx":733 * self._polled_offers = {} * * def _reject(self, offer): # <<<<<<<<<<<<<< @@ -10557,7 +9477,7 @@ static PyObject *__pyx_pf_5trade_5Trade_32_reject(CYTHON_UNUSED PyObject *__pyx_ return __pyx_r; } -/* "trade.pyx":650 +/* "trade.pyx":743 * self._send(offer.sender, 'abce_receive_reject', offer.id) * * def reject(self, Offer offer): # <<<<<<<<<<<<<< @@ -10566,10 +9486,10 @@ static PyObject *__pyx_pf_5trade_5Trade_32_reject(CYTHON_UNUSED PyObject *__pyx_ */ /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_35reject(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_5trade_5Trade_34reject[] = " Rejects and offer, if the offer is subsequently accepted in the\n same subround it is accepted'. Peaked offers can not be rejected.\n\n Args:\n\n offer:\n the offer to be rejected\n "; -static PyMethodDef __pyx_mdef_5trade_5Trade_35reject = {"reject", (PyCFunction)__pyx_pw_5trade_5Trade_35reject, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_34reject}; -static PyObject *__pyx_pw_5trade_5Trade_35reject(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5trade_5Trade_29reject(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5trade_5Trade_28reject[] = " Rejects and offer, if the offer is subsequently accepted in the\n same subround it is accepted'. Peaked offers can not be rejected.\n\n Args:\n\n offer:\n the offer to be rejected\n "; +static PyMethodDef __pyx_mdef_5trade_5Trade_29reject = {"reject", (PyCFunction)__pyx_pw_5trade_5Trade_29reject, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_28reject}; +static PyObject *__pyx_pw_5trade_5Trade_29reject(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { CYTHON_UNUSED PyObject *__pyx_v_self = 0; CYTHON_UNUSED struct __pyx_obj_5trade_Offer *__pyx_v_offer = 0; PyObject *__pyx_r = 0; @@ -10598,11 +9518,11 @@ static PyObject *__pyx_pw_5trade_5Trade_35reject(PyObject *__pyx_self, PyObject case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_offer)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("reject", 1, 2, 2, 1); __PYX_ERR(0, 650, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("reject", 1, 2, 2, 1); __PYX_ERR(0, 743, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "reject") < 0)) __PYX_ERR(0, 650, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "reject") < 0)) __PYX_ERR(0, 743, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -10615,14 +9535,14 @@ static PyObject *__pyx_pw_5trade_5Trade_35reject(PyObject *__pyx_self, PyObject } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("reject", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 650, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("reject", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 743, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade.reject", __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, 650, __pyx_L1_error) - __pyx_r = __pyx_pf_5trade_5Trade_34reject(__pyx_self, __pyx_v_self, __pyx_v_offer); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_offer), __pyx_ptype_5trade_Offer, 1, "offer", 0))) __PYX_ERR(0, 743, __pyx_L1_error) + __pyx_r = __pyx_pf_5trade_5Trade_28reject(__pyx_self, __pyx_v_self, __pyx_v_offer); /* function exit code */ goto __pyx_L0; @@ -10633,7 +9553,7 @@ static PyObject *__pyx_pw_5trade_5Trade_35reject(PyObject *__pyx_self, PyObject return __pyx_r; } -static PyObject *__pyx_pf_5trade_5Trade_34reject(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED struct __pyx_obj_5trade_Offer *__pyx_v_offer) { +static PyObject *__pyx_pf_5trade_5Trade_28reject(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED struct __pyx_obj_5trade_Offer *__pyx_v_offer) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("reject", 0); @@ -10645,7 +9565,7 @@ static PyObject *__pyx_pf_5trade_5Trade_34reject(CYTHON_UNUSED PyObject *__pyx_s return __pyx_r; } -/* "trade.pyx":661 +/* "trade.pyx":754 * pass * * def _log_receive_accept_group(self, offer): # <<<<<<<<<<<<<< @@ -10654,9 +9574,9 @@ static PyObject *__pyx_pf_5trade_5Trade_34reject(CYTHON_UNUSED PyObject *__pyx_s */ /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_37_log_receive_accept_group(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5trade_5Trade_37_log_receive_accept_group = {"_log_receive_accept_group", (PyCFunction)__pyx_pw_5trade_5Trade_37_log_receive_accept_group, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_5trade_5Trade_37_log_receive_accept_group(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5trade_5Trade_31_log_receive_accept_group(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_5trade_5Trade_31_log_receive_accept_group = {"_log_receive_accept_group", (PyCFunction)__pyx_pw_5trade_5Trade_31_log_receive_accept_group, METH_VARARGS|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_5trade_5Trade_31_log_receive_accept_group(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_offer = 0; PyObject *__pyx_r = 0; @@ -10685,11 +9605,11 @@ static PyObject *__pyx_pw_5trade_5Trade_37_log_receive_accept_group(PyObject *__ case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_offer)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_log_receive_accept_group", 1, 2, 2, 1); __PYX_ERR(0, 661, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("_log_receive_accept_group", 1, 2, 2, 1); __PYX_ERR(0, 754, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_log_receive_accept_group") < 0)) __PYX_ERR(0, 661, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_log_receive_accept_group") < 0)) __PYX_ERR(0, 754, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -10702,20 +9622,20 @@ static PyObject *__pyx_pw_5trade_5Trade_37_log_receive_accept_group(PyObject *__ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_log_receive_accept_group", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 661, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("_log_receive_accept_group", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 754, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade._log_receive_accept_group", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5trade_5Trade_36_log_receive_accept_group(__pyx_self, __pyx_v_self, __pyx_v_offer); + __pyx_r = __pyx_pf_5trade_5Trade_30_log_receive_accept_group(__pyx_self, __pyx_v_self, __pyx_v_offer); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_5trade_5Trade_36_log_receive_accept_group(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer) { +static PyObject *__pyx_pf_5trade_5Trade_30_log_receive_accept_group(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -10727,40 +9647,40 @@ static PyObject *__pyx_pf_5trade_5Trade_36_log_receive_accept_group(CYTHON_UNUSE PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("_log_receive_accept_group", 0); - /* "trade.pyx":662 + /* "trade.pyx":755 * * def _log_receive_accept_group(self, offer): * if offer.sell: # <<<<<<<<<<<<<< * self._trade_log[(offer.good, self.group, offer.receiver[0], 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, 755, __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, 755, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "trade.pyx":663 + /* "trade.pyx":756 * def _log_receive_accept_group(self, offer): * if offer.sell: * self._trade_log[(offer.good, self.group, offer.receiver[0], offer.price)] += offer.quantity # <<<<<<<<<<<<<< * else: * self._trade_log[(offer.good, offer.receiver[0], self.group, offer.price)] += offer.quantity */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__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(__pyx_v_self, __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 756, __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, 756, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 663, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 756, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver); 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); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 756, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 663, __pyx_L1_error) + __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 756, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 663, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 756, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 663, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 756, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); @@ -10774,20 +9694,20 @@ static PyObject *__pyx_pf_5trade_5Trade_36_log_receive_accept_group(CYTHON_UNUSE __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 663, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 756, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __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, 756, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 663, __pyx_L1_error) + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 756, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_7, __pyx_t_4) < 0)) __PYX_ERR(0, 663, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_7, __pyx_t_4) < 0)) __PYX_ERR(0, 756, __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":662 + /* "trade.pyx":755 * * def _log_receive_accept_group(self, offer): * if offer.sell: # <<<<<<<<<<<<<< @@ -10797,7 +9717,7 @@ static PyObject *__pyx_pf_5trade_5Trade_36_log_receive_accept_group(CYTHON_UNUSE goto __pyx_L3; } - /* "trade.pyx":665 + /* "trade.pyx":758 * self._trade_log[(offer.good, self.group, offer.receiver[0], offer.price)] += offer.quantity * else: * self._trade_log[(offer.good, offer.receiver[0], self.group, offer.price)] += offer.quantity # <<<<<<<<<<<<<< @@ -10805,20 +9725,20 @@ static PyObject *__pyx_pf_5trade_5Trade_36_log_receive_accept_group(CYTHON_UNUSE * def _log_receive_accept_agent(self, offer): */ /*else*/ { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__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(__pyx_v_self, __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 758, __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, 665, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 758, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver); 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); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 758, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 665, __pyx_L1_error) + __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 758, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 665, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 758, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 665, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 758, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __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, 758, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); @@ -10832,22 +9752,22 @@ static PyObject *__pyx_pf_5trade_5Trade_36_log_receive_accept_group(CYTHON_UNUSE __pyx_t_6 = 0; __pyx_t_4 = 0; __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 665, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 758, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_quantity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 665, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_quantity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 758, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 665, __pyx_L1_error) + __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 758, __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; - 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, 758, __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":754 * pass * * def _log_receive_accept_group(self, offer): # <<<<<<<<<<<<<< @@ -10873,7 +9793,7 @@ static PyObject *__pyx_pf_5trade_5Trade_36_log_receive_accept_group(CYTHON_UNUSE return __pyx_r; } -/* "trade.pyx":667 +/* "trade.pyx":760 * self._trade_log[(offer.good, offer.receiver[0], self.group, offer.price)] += offer.quantity * * def _log_receive_accept_agent(self, offer): # <<<<<<<<<<<<<< @@ -10882,9 +9802,9 @@ static PyObject *__pyx_pf_5trade_5Trade_36_log_receive_accept_group(CYTHON_UNUSE */ /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_39_log_receive_accept_agent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5trade_5Trade_39_log_receive_accept_agent = {"_log_receive_accept_agent", (PyCFunction)__pyx_pw_5trade_5Trade_39_log_receive_accept_agent, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_5trade_5Trade_39_log_receive_accept_agent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5trade_5Trade_33_log_receive_accept_agent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_5trade_5Trade_33_log_receive_accept_agent = {"_log_receive_accept_agent", (PyCFunction)__pyx_pw_5trade_5Trade_33_log_receive_accept_agent, METH_VARARGS|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_5trade_5Trade_33_log_receive_accept_agent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_offer = 0; PyObject *__pyx_r = 0; @@ -10913,11 +9833,11 @@ static PyObject *__pyx_pw_5trade_5Trade_39_log_receive_accept_agent(PyObject *__ case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_offer)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_log_receive_accept_agent", 1, 2, 2, 1); __PYX_ERR(0, 667, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("_log_receive_accept_agent", 1, 2, 2, 1); __PYX_ERR(0, 760, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_log_receive_accept_agent") < 0)) __PYX_ERR(0, 667, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_log_receive_accept_agent") < 0)) __PYX_ERR(0, 760, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -10930,20 +9850,20 @@ static PyObject *__pyx_pw_5trade_5Trade_39_log_receive_accept_agent(PyObject *__ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_log_receive_accept_agent", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 667, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("_log_receive_accept_agent", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 760, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade._log_receive_accept_agent", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5trade_5Trade_38_log_receive_accept_agent(__pyx_self, __pyx_v_self, __pyx_v_offer); + __pyx_r = __pyx_pf_5trade_5Trade_32_log_receive_accept_agent(__pyx_self, __pyx_v_self, __pyx_v_offer); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_5trade_5Trade_38_log_receive_accept_agent(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer) { +static PyObject *__pyx_pf_5trade_5Trade_32_log_receive_accept_agent(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -10955,51 +9875,51 @@ static PyObject *__pyx_pf_5trade_5Trade_38_log_receive_accept_agent(CYTHON_UNUSE PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("_log_receive_accept_agent", 0); - /* "trade.pyx":668 + /* "trade.pyx":761 * * def _log_receive_accept_agent(self, offer): * if offer.sell: # <<<<<<<<<<<<<< * self._trade_log[(offer.good, self.name_without_colon, '%s_%i' % ( * offer.receiver[0], offer.receiver[1]), offer.price)] += offer.quantity */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_sell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 668, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_sell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 761, __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, 668, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 761, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "trade.pyx":669 + /* "trade.pyx":762 * def _log_receive_accept_agent(self, offer): * if offer.sell: * self._trade_log[(offer.good, self.name_without_colon, '%s_%i' % ( # <<<<<<<<<<<<<< * offer.receiver[0], offer.receiver[1]), offer.price)] += offer.quantity * else: */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 669, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 762, __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, 669, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 762, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name_without_colon); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 669, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name_without_colon); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 762, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - /* "trade.pyx":670 + /* "trade.pyx":763 * if offer.sell: * self._trade_log[(offer.good, self.name_without_colon, '%s_%i' % ( * offer.receiver[0], offer.receiver[1]), offer.price)] += offer.quantity # <<<<<<<<<<<<<< * else: * self._trade_log[(offer.good, '%s_%i' % ( */ - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 670, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 670, __pyx_L1_error) + __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 670, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_5, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 670, __pyx_L1_error) + __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_5, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 670, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); @@ -11008,35 +9928,35 @@ static PyObject *__pyx_pf_5trade_5Trade_38_log_receive_accept_agent(CYTHON_UNUSE __pyx_t_6 = 0; __pyx_t_7 = 0; - /* "trade.pyx":669 + /* "trade.pyx":762 * def _log_receive_accept_agent(self, offer): * if offer.sell: * self._trade_log[(offer.good, self.name_without_colon, '%s_%i' % ( # <<<<<<<<<<<<<< * offer.receiver[0], offer.receiver[1]), offer.price)] += offer.quantity * else: */ - __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_s__i, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 669, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_s__i, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 762, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - /* "trade.pyx":670 + /* "trade.pyx":763 * if offer.sell: * self._trade_log[(offer.good, self.name_without_colon, '%s_%i' % ( * offer.receiver[0], offer.receiver[1]), offer.price)] += offer.quantity # <<<<<<<<<<<<<< * else: * self._trade_log[(offer.good, '%s_%i' % ( */ - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 670, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - /* "trade.pyx":669 + /* "trade.pyx":762 * def _log_receive_accept_agent(self, offer): * if offer.sell: * self._trade_log[(offer.good, self.name_without_colon, '%s_%i' % ( # <<<<<<<<<<<<<< * offer.receiver[0], offer.receiver[1]), offer.price)] += offer.quantity * else: */ - __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 669, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 762, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); @@ -11050,36 +9970,36 @@ static PyObject *__pyx_pf_5trade_5Trade_38_log_receive_accept_agent(CYTHON_UNUSE __pyx_t_4 = 0; __pyx_t_7 = 0; __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 669, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 762, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - /* "trade.pyx":670 + /* "trade.pyx":763 * if offer.sell: * self._trade_log[(offer.good, self.name_without_colon, '%s_%i' % ( * offer.receiver[0], offer.receiver[1]), offer.price)] += offer.quantity # <<<<<<<<<<<<<< * else: * self._trade_log[(offer.good, '%s_%i' % ( */ - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_quantity); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 670, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_quantity); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - /* "trade.pyx":669 + /* "trade.pyx":762 * def _log_receive_accept_agent(self, offer): * if offer.sell: * self._trade_log[(offer.good, self.name_without_colon, '%s_%i' % ( # <<<<<<<<<<<<<< * offer.receiver[0], offer.receiver[1]), offer.price)] += offer.quantity * else: */ - __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 669, __pyx_L1_error) + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 762, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_6, __pyx_t_4) < 0)) __PYX_ERR(0, 669, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_6, __pyx_t_4) < 0)) __PYX_ERR(0, 762, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":668 + /* "trade.pyx":761 * * def _log_receive_accept_agent(self, offer): * if offer.sell: # <<<<<<<<<<<<<< @@ -11089,7 +10009,7 @@ static PyObject *__pyx_pf_5trade_5Trade_38_log_receive_accept_agent(CYTHON_UNUSE goto __pyx_L3; } - /* "trade.pyx":672 + /* "trade.pyx":765 * offer.receiver[0], offer.receiver[1]), offer.price)] += offer.quantity * else: * self._trade_log[(offer.good, '%s_%i' % ( # <<<<<<<<<<<<<< @@ -11097,29 +10017,29 @@ static PyObject *__pyx_pf_5trade_5Trade_38_log_receive_accept_agent(CYTHON_UNUSE * */ /*else*/ { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 672, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 765, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 672, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 765, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - /* "trade.pyx":673 + /* "trade.pyx":766 * else: * self._trade_log[(offer.good, '%s_%i' % ( * offer.receiver[0], offer.receiver[1]), self.name_without_colon, offer.price)] += offer.quantity # <<<<<<<<<<<<<< * * def _receive_accept(self, offer_id_final_quantity): */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 673, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 766, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 673, __pyx_L1_error) + __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 766, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 673, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_receiver); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 766, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 673, __pyx_L1_error) + __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 766, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 673, __pyx_L1_error) + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 766, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_7); @@ -11128,37 +10048,37 @@ static PyObject *__pyx_pf_5trade_5Trade_38_log_receive_accept_agent(CYTHON_UNUSE __pyx_t_7 = 0; __pyx_t_5 = 0; - /* "trade.pyx":672 + /* "trade.pyx":765 * offer.receiver[0], offer.receiver[1]), offer.price)] += offer.quantity * else: * self._trade_log[(offer.good, '%s_%i' % ( # <<<<<<<<<<<<<< * offer.receiver[0], offer.receiver[1]), self.name_without_colon, offer.price)] += offer.quantity * */ - __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_s__i, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 672, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_s__i, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 765, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "trade.pyx":673 + /* "trade.pyx":766 * else: * self._trade_log[(offer.good, '%s_%i' % ( * offer.receiver[0], offer.receiver[1]), self.name_without_colon, offer.price)] += offer.quantity # <<<<<<<<<<<<<< * * def _receive_accept(self, offer_id_final_quantity): */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name_without_colon); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 673, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name_without_colon); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 766, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 673, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 766, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - /* "trade.pyx":672 + /* "trade.pyx":765 * offer.receiver[0], offer.receiver[1]), offer.price)] += offer.quantity * else: * self._trade_log[(offer.good, '%s_%i' % ( # <<<<<<<<<<<<<< * offer.receiver[0], offer.receiver[1]), self.name_without_colon, offer.price)] += offer.quantity * */ - __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 672, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 765, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); @@ -11172,38 +10092,38 @@ static PyObject *__pyx_pf_5trade_5Trade_38_log_receive_accept_agent(CYTHON_UNUSE __pyx_t_5 = 0; __pyx_t_4 = 0; __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 672, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 765, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - /* "trade.pyx":673 + /* "trade.pyx":766 * else: * self._trade_log[(offer.good, '%s_%i' % ( * offer.receiver[0], offer.receiver[1]), self.name_without_colon, offer.price)] += offer.quantity # <<<<<<<<<<<<<< * * def _receive_accept(self, offer_id_final_quantity): */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_quantity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 673, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_quantity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 766, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - /* "trade.pyx":672 + /* "trade.pyx":765 * offer.receiver[0], offer.receiver[1]), offer.price)] += offer.quantity * else: * self._trade_log[(offer.good, '%s_%i' % ( # <<<<<<<<<<<<<< * offer.receiver[0], offer.receiver[1]), self.name_without_colon, offer.price)] += offer.quantity * */ - __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_7, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 672, __pyx_L1_error) + __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_7, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 765, __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 (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_3, __pyx_t_5) < 0)) __PYX_ERR(0, 672, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_3, __pyx_t_5) < 0)) __PYX_ERR(0, 765, __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_1); __pyx_t_1 = 0; } __pyx_L3:; - /* "trade.pyx":667 + /* "trade.pyx":760 * self._trade_log[(offer.good, offer.receiver[0], self.group, offer.price)] += offer.quantity * * def _log_receive_accept_agent(self, offer): # <<<<<<<<<<<<<< @@ -11229,7 +10149,7 @@ static PyObject *__pyx_pf_5trade_5Trade_38_log_receive_accept_agent(CYTHON_UNUSE return __pyx_r; } -/* "trade.pyx":675 +/* "trade.pyx":768 * offer.receiver[0], offer.receiver[1]), self.name_without_colon, offer.price)] += offer.quantity * * def _receive_accept(self, offer_id_final_quantity): # <<<<<<<<<<<<<< @@ -11238,10 +10158,10 @@ static PyObject *__pyx_pf_5trade_5Trade_38_log_receive_accept_agent(CYTHON_UNUSE */ /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_41_receive_accept(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_5trade_5Trade_40_receive_accept[] = " When the other party partially accepted the money or good is\n received, remaining good or money is added back to haves and the offer\n is deleted\n "; -static PyMethodDef __pyx_mdef_5trade_5Trade_41_receive_accept = {"_receive_accept", (PyCFunction)__pyx_pw_5trade_5Trade_41_receive_accept, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_40_receive_accept}; -static PyObject *__pyx_pw_5trade_5Trade_41_receive_accept(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5trade_5Trade_35_receive_accept(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5trade_5Trade_34_receive_accept[] = " When the other party partially accepted the money or good is\n received, remaining good or money is added back to haves and the offer\n is deleted\n "; +static PyMethodDef __pyx_mdef_5trade_5Trade_35_receive_accept = {"_receive_accept", (PyCFunction)__pyx_pw_5trade_5Trade_35_receive_accept, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_34_receive_accept}; +static PyObject *__pyx_pw_5trade_5Trade_35_receive_accept(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_offer_id_final_quantity = 0; PyObject *__pyx_r = 0; @@ -11270,11 +10190,11 @@ static PyObject *__pyx_pw_5trade_5Trade_41_receive_accept(PyObject *__pyx_self, case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_offer_id_final_quantity)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_receive_accept", 1, 2, 2, 1); __PYX_ERR(0, 675, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("_receive_accept", 1, 2, 2, 1); __PYX_ERR(0, 768, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_receive_accept") < 0)) __PYX_ERR(0, 675, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_receive_accept") < 0)) __PYX_ERR(0, 768, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -11287,20 +10207,20 @@ static PyObject *__pyx_pw_5trade_5Trade_41_receive_accept(PyObject *__pyx_self, } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_receive_accept", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 675, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("_receive_accept", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 768, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade._receive_accept", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5trade_5Trade_40_receive_accept(__pyx_self, __pyx_v_self, __pyx_v_offer_id_final_quantity); + __pyx_r = __pyx_pf_5trade_5Trade_34_receive_accept(__pyx_self, __pyx_v_self, __pyx_v_offer_id_final_quantity); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_5trade_5Trade_40_receive_accept(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer_id_final_quantity) { +static PyObject *__pyx_pf_5trade_5Trade_34_receive_accept(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer_id_final_quantity) { struct __pyx_obj_5trade_Offer *__pyx_v_offer = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -11316,39 +10236,39 @@ static PyObject *__pyx_pf_5trade_5Trade_40_receive_accept(CYTHON_UNUSED PyObject PyObject *__pyx_t_10 = NULL; __Pyx_RefNannySetupContext("_receive_accept", 0); - /* "trade.pyx":680 + /* "trade.pyx":773 * 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(__pyx_v_self, __pyx_n_s_given_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 680, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_given_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 773, __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, 680, __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, 773, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 680, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 773, __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, 680, __pyx_L1_error) + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5trade_Offer))))) __PYX_ERR(0, 773, __pyx_L1_error) __pyx_v_offer = ((struct __pyx_obj_5trade_Offer *)__pyx_t_3); __pyx_t_3 = 0; - /* "trade.pyx":681 + /* "trade.pyx":774 * """ * cdef Offer offer = self.given_offers[offer_id_final_quantity[0]] * offer.final_quantity = offer_id_final_quantity[1] # <<<<<<<<<<<<<< * if offer.sell: * 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, 681, __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, 774, __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, 681, __pyx_L1_error) + __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_4 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 774, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_offer->final_quantity = __pyx_t_4; - /* "trade.pyx":682 + /* "trade.pyx":775 * cdef Offer offer = self.given_offers[offer_id_final_quantity[0]] * offer.final_quantity = offer_id_final_quantity[1] * if offer.sell: # <<<<<<<<<<<<<< @@ -11358,21 +10278,21 @@ static PyObject *__pyx_pf_5trade_5Trade_40_receive_accept(CYTHON_UNUSED PyObject __pyx_t_5 = (__pyx_v_offer->sell != 0); if (__pyx_t_5) { - /* "trade.pyx":683 + /* "trade.pyx":776 * offer.final_quantity = offer_id_final_quantity[1] * if offer.sell: * self._inventory.commit(offer.good, offer.quantity, offer.final_quantity) # <<<<<<<<<<<<<< * self._inventory.haves[offer.currency] += offer.final_quantity * offer.price * else: */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 683, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 776, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_commit); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 683, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_commit); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 776, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __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, 683, __pyx_L1_error) + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_offer->quantity); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 776, __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, 683, __pyx_L1_error) + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_offer->final_quantity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 776, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_8 = 0; @@ -11389,7 +10309,7 @@ static PyObject *__pyx_pf_5trade_5Trade_40_receive_accept(CYTHON_UNUSED PyObject #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, 683, __pyx_L1_error) + __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, 776, __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; @@ -11399,7 +10319,7 @@ static PyObject *__pyx_pf_5trade_5Trade_40_receive_accept(CYTHON_UNUSED PyObject #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, 683, __pyx_L1_error) + __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, 776, __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; @@ -11407,7 +10327,7 @@ static PyObject *__pyx_pf_5trade_5Trade_40_receive_accept(CYTHON_UNUSED PyObject } else #endif { - __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 683, __pyx_L1_error) + __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 776, __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; @@ -11421,41 +10341,41 @@ static PyObject *__pyx_pf_5trade_5Trade_40_receive_accept(CYTHON_UNUSED PyObject 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, 683, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 776, __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; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "trade.pyx":684 + /* "trade.pyx":777 * if offer.sell: * self._inventory.commit(offer.good, offer.quantity, offer.final_quantity) * self._inventory.haves[offer.currency] += offer.final_quantity * offer.price # <<<<<<<<<<<<<< * else: * self._inventory.haves[offer.good] += offer.final_quantity */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 684, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 777, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_haves); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 684, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_haves); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 777, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __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 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 684, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 777, __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, 684, __pyx_L1_error) + __pyx_t_9 = PyFloat_FromDouble((__pyx_v_offer->final_quantity * __pyx_v_offer->price)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 777, __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, 684, __pyx_L1_error) + __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 777, __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, 684, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_10, __pyx_t_6) < 0)) __PYX_ERR(0, 777, __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":682 + /* "trade.pyx":775 * cdef Offer offer = self.given_offers[offer_id_final_quantity[0]] * offer.final_quantity = offer_id_final_quantity[1] * if offer.sell: # <<<<<<<<<<<<<< @@ -11465,7 +10385,7 @@ static PyObject *__pyx_pf_5trade_5Trade_40_receive_accept(CYTHON_UNUSED PyObject goto __pyx_L3; } - /* "trade.pyx":686 + /* "trade.pyx":779 * self._inventory.haves[offer.currency] += offer.final_quantity * offer.price * else: * self._inventory.haves[offer.good] += offer.final_quantity # <<<<<<<<<<<<<< @@ -11473,41 +10393,41 @@ static PyObject *__pyx_pf_5trade_5Trade_40_receive_accept(CYTHON_UNUSED PyObject * offer.status = "accepted" */ /*else*/ { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 686, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 779, __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, 686, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_haves); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 779, __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_1 = __pyx_v_offer->good; - __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 686, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 779, __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, 686, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_offer->final_quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 779, __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, 686, __pyx_L1_error) + __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 779, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __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, 686, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_6, __pyx_t_1, __pyx_t_2) < 0)) __PYX_ERR(0, 779, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "trade.pyx":687 + /* "trade.pyx":780 * else: * 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.time */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 687, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 780, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_commit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 687, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_commit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 780, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyFloat_FromDouble((__pyx_v_offer->quantity * __pyx_v_offer->price)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 687, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble((__pyx_v_offer->quantity * __pyx_v_offer->price)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 780, __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, 687, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble((__pyx_v_offer->final_quantity * __pyx_v_offer->price)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 780, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = NULL; __pyx_t_8 = 0; @@ -11524,7 +10444,7 @@ static PyObject *__pyx_pf_5trade_5Trade_40_receive_accept(CYTHON_UNUSED PyObject #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, 687, __pyx_L1_error) + __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, 780, __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; @@ -11534,7 +10454,7 @@ static PyObject *__pyx_pf_5trade_5Trade_40_receive_accept(CYTHON_UNUSED PyObject #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, 687, __pyx_L1_error) + __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, 780, __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; @@ -11542,7 +10462,7 @@ static PyObject *__pyx_pf_5trade_5Trade_40_receive_accept(CYTHON_UNUSED PyObject } else #endif { - __pyx_t_7 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 687, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 780, __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; @@ -11556,7 +10476,7 @@ static PyObject *__pyx_pf_5trade_5Trade_40_receive_accept(CYTHON_UNUSED PyObject 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, 687, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 780, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } @@ -11565,7 +10485,7 @@ static PyObject *__pyx_pf_5trade_5Trade_40_receive_accept(CYTHON_UNUSED PyObject } __pyx_L3:; - /* "trade.pyx":688 + /* "trade.pyx":781 * 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" # <<<<<<<<<<<<<< @@ -11578,32 +10498,32 @@ static PyObject *__pyx_pf_5trade_5Trade_40_receive_accept(CYTHON_UNUSED PyObject __Pyx_DECREF(__pyx_v_offer->status); __pyx_v_offer->status = __pyx_n_s_accepted; - /* "trade.pyx":689 + /* "trade.pyx":782 * self._inventory.commit(offer.currency, offer.quantity * offer.price, offer.final_quantity * offer.price) * offer.status = "accepted" * offer.status_round = self.time # <<<<<<<<<<<<<< * del self.given_offers[offer.id] * return offer */ - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_time); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 689, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_time); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 782, __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, 689, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_6); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 782, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_offer->status_round = __pyx_t_8; - /* "trade.pyx":690 + /* "trade.pyx":783 * offer.status = "accepted" * offer.status_round = self.time * del self.given_offers[offer.id] # <<<<<<<<<<<<<< * return offer * */ - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_given_offers); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 690, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_given_offers); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 783, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - if (unlikely(PyObject_DelItem(__pyx_t_6, __pyx_v_offer->id) < 0)) __PYX_ERR(0, 690, __pyx_L1_error) + if (unlikely(PyObject_DelItem(__pyx_t_6, __pyx_v_offer->id) < 0)) __PYX_ERR(0, 783, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "trade.pyx":691 + /* "trade.pyx":784 * offer.status_round = self.time * del self.given_offers[offer.id] * return offer # <<<<<<<<<<<<<< @@ -11615,7 +10535,7 @@ static PyObject *__pyx_pf_5trade_5Trade_40_receive_accept(CYTHON_UNUSED PyObject __pyx_r = ((PyObject *)__pyx_v_offer); goto __pyx_L0; - /* "trade.pyx":675 + /* "trade.pyx":768 * offer.receiver[0], offer.receiver[1]), self.name_without_colon, offer.price)] += offer.quantity * * def _receive_accept(self, offer_id_final_quantity): # <<<<<<<<<<<<<< @@ -11641,7 +10561,7 @@ static PyObject *__pyx_pf_5trade_5Trade_40_receive_accept(CYTHON_UNUSED PyObject return __pyx_r; } -/* "trade.pyx":693 +/* "trade.pyx":786 * return offer * * def _log_receive_accept_group(self, offer): # <<<<<<<<<<<<<< @@ -11650,9 +10570,9 @@ static PyObject *__pyx_pf_5trade_5Trade_40_receive_accept(CYTHON_UNUSED PyObject */ /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_43_log_receive_accept_group(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5trade_5Trade_43_log_receive_accept_group = {"_log_receive_accept_group", (PyCFunction)__pyx_pw_5trade_5Trade_43_log_receive_accept_group, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_5trade_5Trade_43_log_receive_accept_group(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5trade_5Trade_37_log_receive_accept_group(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_5trade_5Trade_37_log_receive_accept_group = {"_log_receive_accept_group", (PyCFunction)__pyx_pw_5trade_5Trade_37_log_receive_accept_group, METH_VARARGS|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_5trade_5Trade_37_log_receive_accept_group(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_offer = 0; PyObject *__pyx_r = 0; @@ -11681,11 +10601,11 @@ static PyObject *__pyx_pw_5trade_5Trade_43_log_receive_accept_group(PyObject *__ case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_offer)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_log_receive_accept_group", 1, 2, 2, 1); __PYX_ERR(0, 693, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("_log_receive_accept_group", 1, 2, 2, 1); __PYX_ERR(0, 786, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_log_receive_accept_group") < 0)) __PYX_ERR(0, 693, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_log_receive_accept_group") < 0)) __PYX_ERR(0, 786, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -11698,20 +10618,20 @@ static PyObject *__pyx_pw_5trade_5Trade_43_log_receive_accept_group(PyObject *__ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_log_receive_accept_group", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 693, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("_log_receive_accept_group", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 786, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade._log_receive_accept_group", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5trade_5Trade_42_log_receive_accept_group(__pyx_self, __pyx_v_self, __pyx_v_offer); + __pyx_r = __pyx_pf_5trade_5Trade_36_log_receive_accept_group(__pyx_self, __pyx_v_self, __pyx_v_offer); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_5trade_5Trade_42_log_receive_accept_group(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer) { +static PyObject *__pyx_pf_5trade_5Trade_36_log_receive_accept_group(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -11723,37 +10643,37 @@ static PyObject *__pyx_pf_5trade_5Trade_42_log_receive_accept_group(CYTHON_UNUSE PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("_log_receive_accept_group", 0); - /* "trade.pyx":694 + /* "trade.pyx":787 * * 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, 694, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_sell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 787, __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, 694, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 787, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "trade.pyx":695 + /* "trade.pyx":788 * 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(__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(__pyx_v_self, __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 788, __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, 695, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 695, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 788, __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, 695, __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, 788, __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, 695, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 695, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); @@ -11767,20 +10687,20 @@ static PyObject *__pyx_pf_5trade_5Trade_42_log_receive_accept_group(CYTHON_UNUSE __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 695, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 788, __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, 695, __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, 788, __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, 695, __pyx_L1_error) + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 788, __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, 695, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_7, __pyx_t_4) < 0)) __PYX_ERR(0, 788, __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":694 + /* "trade.pyx":787 * * def _log_receive_accept_group(self, offer): * if offer.sell: # <<<<<<<<<<<<<< @@ -11790,7 +10710,7 @@ static PyObject *__pyx_pf_5trade_5Trade_42_log_receive_accept_group(CYTHON_UNUSE goto __pyx_L3; } - /* "trade.pyx":697 + /* "trade.pyx":790 * 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 # <<<<<<<<<<<<<< @@ -11798,17 +10718,17 @@ static PyObject *__pyx_pf_5trade_5Trade_42_log_receive_accept_group(CYTHON_UNUSE * def _log_receive_accept_agent(self, offer): */ /*else*/ { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 697, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 790, __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, 697, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 790, __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, 697, __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, 790, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_group); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 697, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_group); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 790, __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, 697, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 790, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 697, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 790, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); @@ -11822,22 +10742,22 @@ static PyObject *__pyx_pf_5trade_5Trade_42_log_receive_accept_group(CYTHON_UNUSE __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 697, __pyx_L1_error) + __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 790, __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, 697, __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, 790, __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, 697, __pyx_L1_error) + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 790, __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, 697, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_3, __pyx_t_4) < 0)) __PYX_ERR(0, 790, __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":693 + /* "trade.pyx":786 * return offer * * def _log_receive_accept_group(self, offer): # <<<<<<<<<<<<<< @@ -11863,7 +10783,7 @@ static PyObject *__pyx_pf_5trade_5Trade_42_log_receive_accept_group(CYTHON_UNUSE return __pyx_r; } -/* "trade.pyx":699 +/* "trade.pyx":792 * self._trade_log[(offer.good, offer.receiver_group, self.group, offer.price)] += offer.final_quantity * * def _log_receive_accept_agent(self, offer): # <<<<<<<<<<<<<< @@ -11872,9 +10792,9 @@ static PyObject *__pyx_pf_5trade_5Trade_42_log_receive_accept_group(CYTHON_UNUSE */ /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_45_log_receive_accept_agent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5trade_5Trade_45_log_receive_accept_agent = {"_log_receive_accept_agent", (PyCFunction)__pyx_pw_5trade_5Trade_45_log_receive_accept_agent, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_5trade_5Trade_45_log_receive_accept_agent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5trade_5Trade_39_log_receive_accept_agent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_5trade_5Trade_39_log_receive_accept_agent = {"_log_receive_accept_agent", (PyCFunction)__pyx_pw_5trade_5Trade_39_log_receive_accept_agent, METH_VARARGS|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_5trade_5Trade_39_log_receive_accept_agent(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_offer = 0; PyObject *__pyx_r = 0; @@ -11903,11 +10823,11 @@ static PyObject *__pyx_pw_5trade_5Trade_45_log_receive_accept_agent(PyObject *__ case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_offer)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_log_receive_accept_agent", 1, 2, 2, 1); __PYX_ERR(0, 699, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("_log_receive_accept_agent", 1, 2, 2, 1); __PYX_ERR(0, 792, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_log_receive_accept_agent") < 0)) __PYX_ERR(0, 699, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_log_receive_accept_agent") < 0)) __PYX_ERR(0, 792, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -11920,20 +10840,20 @@ static PyObject *__pyx_pw_5trade_5Trade_45_log_receive_accept_agent(PyObject *__ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_log_receive_accept_agent", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 699, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("_log_receive_accept_agent", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 792, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade._log_receive_accept_agent", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5trade_5Trade_44_log_receive_accept_agent(__pyx_self, __pyx_v_self, __pyx_v_offer); + __pyx_r = __pyx_pf_5trade_5Trade_38_log_receive_accept_agent(__pyx_self, __pyx_v_self, __pyx_v_offer); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_5trade_5Trade_44_log_receive_accept_agent(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer) { +static PyObject *__pyx_pf_5trade_5Trade_38_log_receive_accept_agent(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -11945,37 +10865,37 @@ static PyObject *__pyx_pf_5trade_5Trade_44_log_receive_accept_agent(CYTHON_UNUSE PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("_log_receive_accept_agent", 0); - /* "trade.pyx":700 + /* "trade.pyx":793 * * 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, 700, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_sell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 793, __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, 700, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 793, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "trade.pyx":701 + /* "trade.pyx":794 * 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(__pyx_v_self, __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 701, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 794, __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, 701, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 794, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name_without_colon); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 701, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name_without_colon); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 794, __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, 701, __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, 794, __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, 701, __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, 794, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 701, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 794, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); @@ -11983,12 +10903,12 @@ static PyObject *__pyx_pf_5trade_5Trade_44_log_receive_accept_agent(CYTHON_UNUSE 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, 701, __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, 794, __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, 701, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 794, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 701, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 794, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); @@ -12002,20 +10922,20 @@ static PyObject *__pyx_pf_5trade_5Trade_44_log_receive_accept_agent(CYTHON_UNUSE __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 701, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 794, __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, 701, __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, 794, __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, 701, __pyx_L1_error) + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 794, __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, 701, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_5, __pyx_t_4) < 0)) __PYX_ERR(0, 794, __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":700 + /* "trade.pyx":793 * * def _log_receive_accept_agent(self, offer): * if offer.sell: # <<<<<<<<<<<<<< @@ -12025,7 +10945,7 @@ static PyObject *__pyx_pf_5trade_5Trade_44_log_receive_accept_agent(CYTHON_UNUSE goto __pyx_L3; } - /* "trade.pyx":703 + /* "trade.pyx":796 * 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 # <<<<<<<<<<<<<< @@ -12033,15 +10953,15 @@ static PyObject *__pyx_pf_5trade_5Trade_44_log_receive_accept_agent(CYTHON_UNUSE * def _receive_reject(self, offer_id): */ /*else*/ { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 703, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_trade_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 796, __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, 703, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_good); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 796, __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, 703, __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, 796, __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, 703, __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, 796, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 703, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 796, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); @@ -12049,14 +10969,14 @@ static PyObject *__pyx_pf_5trade_5Trade_44_log_receive_accept_agent(CYTHON_UNUSE 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, 703, __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, 796, __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_self, __pyx_n_s_name_without_colon); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 703, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name_without_colon); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 796, __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, 703, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_offer, __pyx_n_s_price); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 796, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 703, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 796, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); @@ -12070,22 +10990,22 @@ static PyObject *__pyx_pf_5trade_5Trade_44_log_receive_accept_agent(CYTHON_UNUSE __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 703, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 796, __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, 703, __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, 796, __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, 703, __pyx_L1_error) + __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 796, __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, 703, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_t_3, __pyx_t_6) < 0)) __PYX_ERR(0, 796, __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":699 + /* "trade.pyx":792 * self._trade_log[(offer.good, offer.receiver_group, self.group, offer.price)] += offer.final_quantity * * def _log_receive_accept_agent(self, offer): # <<<<<<<<<<<<<< @@ -12111,7 +11031,7 @@ static PyObject *__pyx_pf_5trade_5Trade_44_log_receive_accept_agent(CYTHON_UNUSE return __pyx_r; } -/* "trade.pyx":705 +/* "trade.pyx":798 * 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): # <<<<<<<<<<<<<< @@ -12120,10 +11040,10 @@ static PyObject *__pyx_pf_5trade_5Trade_44_log_receive_accept_agent(CYTHON_UNUSE */ /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_47_receive_reject(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_5trade_5Trade_46_receive_reject[] = " deletes a given offer\n\n is used by _do_message_clearing, when the other party rejects\n or at the end of the subround when agent retracted the offer\n\n "; -static PyMethodDef __pyx_mdef_5trade_5Trade_47_receive_reject = {"_receive_reject", (PyCFunction)__pyx_pw_5trade_5Trade_47_receive_reject, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_46_receive_reject}; -static PyObject *__pyx_pw_5trade_5Trade_47_receive_reject(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5trade_5Trade_41_receive_reject(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5trade_5Trade_40_receive_reject[] = " deletes a given offer\n\n is used by _do_message_clearing, when the other party rejects\n or at the end of the subround when agent retracted the offer\n\n "; +static PyMethodDef __pyx_mdef_5trade_5Trade_41_receive_reject = {"_receive_reject", (PyCFunction)__pyx_pw_5trade_5Trade_41_receive_reject, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_40_receive_reject}; +static PyObject *__pyx_pw_5trade_5Trade_41_receive_reject(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_offer_id = 0; PyObject *__pyx_r = 0; @@ -12152,11 +11072,11 @@ static PyObject *__pyx_pw_5trade_5Trade_47_receive_reject(PyObject *__pyx_self, case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_offer_id)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_receive_reject", 1, 2, 2, 1); __PYX_ERR(0, 705, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("_receive_reject", 1, 2, 2, 1); __PYX_ERR(0, 798, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_receive_reject") < 0)) __PYX_ERR(0, 705, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_receive_reject") < 0)) __PYX_ERR(0, 798, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -12169,20 +11089,20 @@ static PyObject *__pyx_pw_5trade_5Trade_47_receive_reject(PyObject *__pyx_self, } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_receive_reject", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 705, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("_receive_reject", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 798, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade._receive_reject", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5trade_5Trade_46_receive_reject(__pyx_self, __pyx_v_self, __pyx_v_offer_id); + __pyx_r = __pyx_pf_5trade_5Trade_40_receive_reject(__pyx_self, __pyx_v_self, __pyx_v_offer_id); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_5trade_5Trade_46_receive_reject(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer_id) { +static PyObject *__pyx_pf_5trade_5Trade_40_receive_reject(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer_id) { struct __pyx_obj_5trade_Offer *__pyx_v_offer = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -12195,23 +11115,23 @@ static PyObject *__pyx_pf_5trade_5Trade_46_receive_reject(CYTHON_UNUSED PyObject PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("_receive_reject", 0); - /* "trade.pyx":712 + /* "trade.pyx":805 * * """ * cdef Offer offer = self.given_offers[offer_id] # <<<<<<<<<<<<<< * if offer.sell: * self._inventory.rewind(offer.good, offer.quantity) */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_given_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 712, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_given_offers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 805, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_offer_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 712, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_offer_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 805, __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, 712, __pyx_L1_error) + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5trade_Offer))))) __PYX_ERR(0, 805, __pyx_L1_error) __pyx_v_offer = ((struct __pyx_obj_5trade_Offer *)__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":713 + /* "trade.pyx":806 * """ * cdef Offer offer = self.given_offers[offer_id] * if offer.sell: # <<<<<<<<<<<<<< @@ -12221,19 +11141,19 @@ static PyObject *__pyx_pf_5trade_5Trade_46_receive_reject(CYTHON_UNUSED PyObject __pyx_t_3 = (__pyx_v_offer->sell != 0); if (__pyx_t_3) { - /* "trade.pyx":714 + /* "trade.pyx":807 * cdef Offer offer = self.given_offers[offer_id] * if offer.sell: * self._inventory.rewind(offer.good, offer.quantity) # <<<<<<<<<<<<<< * else: * self._inventory.rewind(offer.currency, offer.quantity * offer.price) */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 714, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 807, __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, 714, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_rewind); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 807, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __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, 714, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_offer->quantity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 807, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = NULL; __pyx_t_6 = 0; @@ -12250,7 +11170,7 @@ static PyObject *__pyx_pf_5trade_5Trade_46_receive_reject(CYTHON_UNUSED PyObject #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, 714, __pyx_L1_error) + __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, 807, __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; @@ -12259,14 +11179,14 @@ static PyObject *__pyx_pf_5trade_5Trade_46_receive_reject(CYTHON_UNUSED PyObject #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, 714, __pyx_L1_error) + __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, 807, __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, 714, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 807, __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; @@ -12277,14 +11197,14 @@ static PyObject *__pyx_pf_5trade_5Trade_46_receive_reject(CYTHON_UNUSED PyObject __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, 714, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 807, __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":713 + /* "trade.pyx":806 * """ * cdef Offer offer = self.given_offers[offer_id] * if offer.sell: # <<<<<<<<<<<<<< @@ -12294,7 +11214,7 @@ static PyObject *__pyx_pf_5trade_5Trade_46_receive_reject(CYTHON_UNUSED PyObject goto __pyx_L3; } - /* "trade.pyx":716 + /* "trade.pyx":809 * self._inventory.rewind(offer.good, offer.quantity) * else: * self._inventory.rewind(offer.currency, offer.quantity * offer.price) # <<<<<<<<<<<<<< @@ -12302,12 +11222,12 @@ static PyObject *__pyx_pf_5trade_5Trade_46_receive_reject(CYTHON_UNUSED PyObject * offer.status_round = self.time */ /*else*/ { - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 716, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 809, __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, 716, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_rewind); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 809, __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, 716, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble((__pyx_v_offer->quantity * __pyx_v_offer->price)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 809, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = NULL; __pyx_t_6 = 0; @@ -12324,7 +11244,7 @@ static PyObject *__pyx_pf_5trade_5Trade_46_receive_reject(CYTHON_UNUSED PyObject #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, 716, __pyx_L1_error) + __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, 809, __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; @@ -12333,14 +11253,14 @@ static PyObject *__pyx_pf_5trade_5Trade_46_receive_reject(CYTHON_UNUSED PyObject #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, 716, __pyx_L1_error) + __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, 809, __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, 716, __pyx_L1_error) + __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 809, __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; @@ -12351,7 +11271,7 @@ static PyObject *__pyx_pf_5trade_5Trade_46_receive_reject(CYTHON_UNUSED PyObject __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, 716, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 809, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } @@ -12360,7 +11280,7 @@ static PyObject *__pyx_pf_5trade_5Trade_46_receive_reject(CYTHON_UNUSED PyObject } __pyx_L3:; - /* "trade.pyx":717 + /* "trade.pyx":810 * else: * self._inventory.rewind(offer.currency, offer.quantity * offer.price) * offer.status = "rejected" # <<<<<<<<<<<<<< @@ -12373,20 +11293,20 @@ static PyObject *__pyx_pf_5trade_5Trade_46_receive_reject(CYTHON_UNUSED PyObject __Pyx_DECREF(__pyx_v_offer->status); __pyx_v_offer->status = __pyx_n_s_rejected; - /* "trade.pyx":718 + /* "trade.pyx":811 * self._inventory.rewind(offer.currency, offer.quantity * offer.price) * offer.status = "rejected" * offer.status_round = self.time # <<<<<<<<<<<<<< * offer.final_quantity = 0 * del self.given_offers[offer_id] */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_time); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 718, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_time); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 811, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 718, __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, 811, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_offer->status_round = __pyx_t_6; - /* "trade.pyx":719 + /* "trade.pyx":812 * offer.status = "rejected" * offer.status_round = self.time * offer.final_quantity = 0 # <<<<<<<<<<<<<< @@ -12395,19 +11315,19 @@ static PyObject *__pyx_pf_5trade_5Trade_46_receive_reject(CYTHON_UNUSED PyObject */ __pyx_v_offer->final_quantity = 0.0; - /* "trade.pyx":720 + /* "trade.pyx":813 * offer.status_round = self.time * offer.final_quantity = 0 * del self.given_offers[offer_id] # <<<<<<<<<<<<<< * * def _delete_given_offer(self, offer_id): */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_given_offers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 720, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_given_offers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 813, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (unlikely(PyObject_DelItem(__pyx_t_2, __pyx_v_offer_id) < 0)) __PYX_ERR(0, 720, __pyx_L1_error) + if (unlikely(PyObject_DelItem(__pyx_t_2, __pyx_v_offer_id) < 0)) __PYX_ERR(0, 813, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":705 + /* "trade.pyx":798 * 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): # <<<<<<<<<<<<<< @@ -12433,7 +11353,7 @@ static PyObject *__pyx_pf_5trade_5Trade_46_receive_reject(CYTHON_UNUSED PyObject return __pyx_r; } -/* "trade.pyx":722 +/* "trade.pyx":815 * del self.given_offers[offer_id] * * def _delete_given_offer(self, offer_id): # <<<<<<<<<<<<<< @@ -12442,9 +11362,9 @@ static PyObject *__pyx_pf_5trade_5Trade_46_receive_reject(CYTHON_UNUSED PyObject */ /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_49_delete_given_offer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5trade_5Trade_49_delete_given_offer = {"_delete_given_offer", (PyCFunction)__pyx_pw_5trade_5Trade_49_delete_given_offer, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_5trade_5Trade_49_delete_given_offer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5trade_5Trade_43_delete_given_offer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_5trade_5Trade_43_delete_given_offer = {"_delete_given_offer", (PyCFunction)__pyx_pw_5trade_5Trade_43_delete_given_offer, METH_VARARGS|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_5trade_5Trade_43_delete_given_offer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_offer_id = 0; PyObject *__pyx_r = 0; @@ -12473,11 +11393,11 @@ static PyObject *__pyx_pw_5trade_5Trade_49_delete_given_offer(PyObject *__pyx_se case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_offer_id)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_delete_given_offer", 1, 2, 2, 1); __PYX_ERR(0, 722, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("_delete_given_offer", 1, 2, 2, 1); __PYX_ERR(0, 815, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_delete_given_offer") < 0)) __PYX_ERR(0, 722, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_delete_given_offer") < 0)) __PYX_ERR(0, 815, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -12490,20 +11410,20 @@ static PyObject *__pyx_pw_5trade_5Trade_49_delete_given_offer(PyObject *__pyx_se } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_delete_given_offer", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 722, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("_delete_given_offer", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 815, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade._delete_given_offer", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5trade_5Trade_48_delete_given_offer(__pyx_self, __pyx_v_self, __pyx_v_offer_id); + __pyx_r = __pyx_pf_5trade_5Trade_42_delete_given_offer(__pyx_self, __pyx_v_self, __pyx_v_offer_id); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_5trade_5Trade_48_delete_given_offer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer_id) { +static PyObject *__pyx_pf_5trade_5Trade_42_delete_given_offer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_offer_id) { struct __pyx_obj_5trade_Offer *__pyx_v_offer = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -12516,16 +11436,16 @@ static PyObject *__pyx_pf_5trade_5Trade_48_delete_given_offer(CYTHON_UNUSED PyOb PyObject *__pyx_t_7 = NULL; __Pyx_RefNannySetupContext("_delete_given_offer", 0); - /* "trade.pyx":723 + /* "trade.pyx":816 * * def _delete_given_offer(self, offer_id): * cdef Offer offer = self.given_offers.pop(offer_id) # <<<<<<<<<<<<<< * if offer.sell: * self._inventory.rewind(offer.good, offer.quantity) */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_given_offers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 723, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_given_offers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 816, __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, 723, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_pop); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 816, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; @@ -12539,13 +11459,13 @@ static PyObject *__pyx_pf_5trade_5Trade_48_delete_given_offer(CYTHON_UNUSED PyOb } } 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, 723, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_offer_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 816, __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, 723, __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, 816, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); } else @@ -12553,29 +11473,29 @@ static PyObject *__pyx_pf_5trade_5Trade_48_delete_given_offer(CYTHON_UNUSED PyOb #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, 723, __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, 816, __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, 723, __pyx_L1_error) + __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 816, __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, 723, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 816, __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, 723, __pyx_L1_error) + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5trade_Offer))))) __PYX_ERR(0, 816, __pyx_L1_error) __pyx_v_offer = ((struct __pyx_obj_5trade_Offer *)__pyx_t_1); __pyx_t_1 = 0; - /* "trade.pyx":724 + /* "trade.pyx":817 * def _delete_given_offer(self, offer_id): * cdef Offer offer = self.given_offers.pop(offer_id) * if offer.sell: # <<<<<<<<<<<<<< @@ -12585,19 +11505,19 @@ static PyObject *__pyx_pf_5trade_5Trade_48_delete_given_offer(CYTHON_UNUSED PyOb __pyx_t_5 = (__pyx_v_offer->sell != 0); if (__pyx_t_5) { - /* "trade.pyx":725 + /* "trade.pyx":818 * cdef Offer offer = self.given_offers.pop(offer_id) * if offer.sell: * self._inventory.rewind(offer.good, offer.quantity) # <<<<<<<<<<<<<< * else: * self._inventory.rewind(offer.currency, offer.quantity * offer.price) */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 725, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 818, __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, 725, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_rewind); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 818, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __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, 725, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_offer->quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 818, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_6 = 0; @@ -12614,7 +11534,7 @@ static PyObject *__pyx_pf_5trade_5Trade_48_delete_given_offer(CYTHON_UNUSED PyOb #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, 725, __pyx_L1_error) + __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, 818, __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; @@ -12623,14 +11543,14 @@ static PyObject *__pyx_pf_5trade_5Trade_48_delete_given_offer(CYTHON_UNUSED PyOb #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, 725, __pyx_L1_error) + __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, 818, __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, 725, __pyx_L1_error) + __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 818, __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; @@ -12641,14 +11561,14 @@ static PyObject *__pyx_pf_5trade_5Trade_48_delete_given_offer(CYTHON_UNUSED PyOb __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, 725, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 818, __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":724 + /* "trade.pyx":817 * def _delete_given_offer(self, offer_id): * cdef Offer offer = self.given_offers.pop(offer_id) * if offer.sell: # <<<<<<<<<<<<<< @@ -12658,7 +11578,7 @@ static PyObject *__pyx_pf_5trade_5Trade_48_delete_given_offer(CYTHON_UNUSED PyOb goto __pyx_L3; } - /* "trade.pyx":727 + /* "trade.pyx":820 * self._inventory.rewind(offer.good, offer.quantity) * else: * self._inventory.rewind(offer.currency, offer.quantity * offer.price) # <<<<<<<<<<<<<< @@ -12666,12 +11586,12 @@ static PyObject *__pyx_pf_5trade_5Trade_48_delete_given_offer(CYTHON_UNUSED PyOb * def give(self, receiver, good, double quantity, double epsilon=epsilon): */ /*else*/ { - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 727, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 820, __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, 727, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_rewind); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 820, __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, 727, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble((__pyx_v_offer->quantity * __pyx_v_offer->price)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 820, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = NULL; __pyx_t_6 = 0; @@ -12688,7 +11608,7 @@ static PyObject *__pyx_pf_5trade_5Trade_48_delete_given_offer(CYTHON_UNUSED PyOb #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, 727, __pyx_L1_error) + __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, 820, __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; @@ -12697,14 +11617,14 @@ static PyObject *__pyx_pf_5trade_5Trade_48_delete_given_offer(CYTHON_UNUSED PyOb #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, 727, __pyx_L1_error) + __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, 820, __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, 727, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 820, __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; @@ -12715,7 +11635,7 @@ static PyObject *__pyx_pf_5trade_5Trade_48_delete_given_offer(CYTHON_UNUSED PyOb __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, 727, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 820, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } @@ -12724,7 +11644,7 @@ static PyObject *__pyx_pf_5trade_5Trade_48_delete_given_offer(CYTHON_UNUSED PyOb } __pyx_L3:; - /* "trade.pyx":722 + /* "trade.pyx":815 * del self.given_offers[offer_id] * * def _delete_given_offer(self, offer_id): # <<<<<<<<<<<<<< @@ -12750,7 +11670,7 @@ static PyObject *__pyx_pf_5trade_5Trade_48_delete_given_offer(CYTHON_UNUSED PyOb return __pyx_r; } -/* "trade.pyx":729 +/* "trade.pyx":822 * self._inventory.rewind(offer.currency, offer.quantity * offer.price) * * def give(self, receiver, good, double quantity, double epsilon=epsilon): # <<<<<<<<<<<<<< @@ -12765,14 +11685,14 @@ static PyObject *__pyx_pf_5trade_10__defaults__(CYTHON_UNUSED PyObject *__pyx_se PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("__defaults__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(__Pyx_CyFunction_Defaults(__pyx_defaults3, __pyx_self)->__pyx_arg_epsilon); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 729, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(__Pyx_CyFunction_Defaults(__pyx_defaults3, __pyx_self)->__pyx_arg_epsilon); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 822, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 729, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 822, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 729, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 822, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); @@ -12797,10 +11717,10 @@ static PyObject *__pyx_pf_5trade_10__defaults__(CYTHON_UNUSED PyObject *__pyx_se } /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_51give(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_5trade_5Trade_50give[] = " gives a good to another agent\n\n Args:\n receiver:\n The name of the receiving agent a tuple (group, id).\n e.G. ('firm', 15)\n good:\n the good to be transfered\n quantity:\n amount to be transfered\n\n epsilon (optional):\n if you have floating point errors, a quantity or prices is\n a fraction of number to high or low. You can increase the\n floating point tolerance. See troubleshooting -- floating point problems\n\n Raises:\n\n AssertionError, when good smaller than 0.\n\n Return:\n Dictionary, with the transfer, which can be used by self.log(...).\n\n Example::\n\n self.log('taxes', self.give('money': 0.05 * self.possession('money'))\n\n "; -static PyMethodDef __pyx_mdef_5trade_5Trade_51give = {"give", (PyCFunction)__pyx_pw_5trade_5Trade_51give, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_50give}; -static PyObject *__pyx_pw_5trade_5Trade_51give(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5trade_5Trade_45give(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5trade_5Trade_44give[] = " gives a good to another agent\n\n Args:\n receiver:\n The name of the receiving agent a tuple (group, id).\n e.G. ('firm', 15)\n good:\n the good to be transfered\n quantity:\n amount to be transfered\n\n epsilon (optional):\n if you have floating point errors, a quantity or prices is\n a fraction of number to high or low. You can increase the\n floating point tolerance. See troubleshooting -- floating point problems\n\n Raises:\n\n AssertionError, when good smaller than 0.\n\n Return:\n Dictionary, with the transfer, which can be used by self.log(...).\n\n Example::\n\n self.log('taxes', self.give('money': 0.05 * self.possession('money'))\n\n "; +static PyMethodDef __pyx_mdef_5trade_5Trade_45give = {"give", (PyCFunction)__pyx_pw_5trade_5Trade_45give, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_44give}; +static PyObject *__pyx_pw_5trade_5Trade_45give(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_receiver = 0; PyObject *__pyx_v_good = 0; @@ -12839,19 +11759,19 @@ static PyObject *__pyx_pw_5trade_5Trade_51give(PyObject *__pyx_self, PyObject *_ case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_receiver)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("give", 0, 4, 5, 1); __PYX_ERR(0, 729, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("give", 0, 4, 5, 1); __PYX_ERR(0, 822, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_good)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("give", 0, 4, 5, 2); __PYX_ERR(0, 729, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("give", 0, 4, 5, 2); __PYX_ERR(0, 822, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_quantity)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("give", 0, 4, 5, 3); __PYX_ERR(0, 729, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("give", 0, 4, 5, 3); __PYX_ERR(0, 822, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: @@ -12861,7 +11781,7 @@ static PyObject *__pyx_pw_5trade_5Trade_51give(PyObject *__pyx_self, PyObject *_ } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "give") < 0)) __PYX_ERR(0, 729, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "give") < 0)) __PYX_ERR(0, 822, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -12878,29 +11798,29 @@ static PyObject *__pyx_pw_5trade_5Trade_51give(PyObject *__pyx_self, PyObject *_ __pyx_v_self = values[0]; __pyx_v_receiver = values[1]; __pyx_v_good = values[2]; - __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 729, __pyx_L3_error) + __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 822, __pyx_L3_error) if (values[4]) { - __pyx_v_epsilon = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_epsilon == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 729, __pyx_L3_error) + __pyx_v_epsilon = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_epsilon == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 822, __pyx_L3_error) } else { __pyx_v_epsilon = __pyx_dynamic_args->__pyx_arg_epsilon; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("give", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 729, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("give", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 822, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade.give", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5trade_5Trade_50give(__pyx_self, __pyx_v_self, __pyx_v_receiver, __pyx_v_good, __pyx_v_quantity, __pyx_v_epsilon); + __pyx_r = __pyx_pf_5trade_5Trade_44give(__pyx_self, __pyx_v_self, __pyx_v_receiver, __pyx_v_good, __pyx_v_quantity, __pyx_v_epsilon); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_receiver, PyObject *__pyx_v_good, double __pyx_v_quantity, double __pyx_v_epsilon) { +static PyObject *__pyx_pf_5trade_5Trade_44give(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_receiver, PyObject *__pyx_v_good, double __pyx_v_quantity, double __pyx_v_epsilon) { double __pyx_v_available; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -12917,7 +11837,7 @@ static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_sel PyObject *__pyx_t_11 = NULL; __Pyx_RefNannySetupContext("give", 0); - /* "trade.pyx":759 + /* "trade.pyx":852 * """ * cdef double available * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) # <<<<<<<<<<<<<< @@ -12927,11 +11847,11 @@ static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_sel #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, 759, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 852, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 759, __pyx_L1_error) + __pyx_t_2 = PyFloat_FromDouble((-__pyx_v_epsilon)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 852, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 759, __pyx_L1_error) + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 852, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); @@ -12939,17 +11859,17 @@ static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_sel 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, 759, __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, 852, __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, 759, __pyx_L1_error) + __PYX_ERR(0, 852, __pyx_L1_error) } } #endif - /* "trade.pyx":760 + /* "trade.pyx":853 * cdef double available * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: # <<<<<<<<<<<<<< @@ -12959,7 +11879,7 @@ static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_4 = ((__pyx_v_quantity < 0.0) != 0); if (__pyx_t_4) { - /* "trade.pyx":761 + /* "trade.pyx":854 * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: * quantity = 0 # <<<<<<<<<<<<<< @@ -12968,7 +11888,7 @@ static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_sel */ __pyx_v_quantity = 0.0; - /* "trade.pyx":760 + /* "trade.pyx":853 * cdef double available * assert quantity > - epsilon, 'quantity %.30f is smaller than 0 - epsilon (%.30f)' % (quantity, - epsilon) * if quantity < 0: # <<<<<<<<<<<<<< @@ -12977,23 +11897,23 @@ static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_sel */ } - /* "trade.pyx":762 + /* "trade.pyx":855 * if quantity < 0: * quantity = 0 * 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(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 762, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 762, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_good); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 855, __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, 762, __pyx_L1_error) + __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 855, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_available = __pyx_t_5; - /* "trade.pyx":763 + /* "trade.pyx":856 * quantity = 0 * available = self._inventory[good] * if quantity > available + epsilon + epsilon * max(quantity, available): # <<<<<<<<<<<<<< @@ -13010,18 +11930,18 @@ static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_4 = ((__pyx_v_quantity > ((__pyx_v_available + __pyx_v_epsilon) + (__pyx_v_epsilon * __pyx_t_7))) != 0); if (unlikely(__pyx_t_4)) { - /* "trade.pyx":764 + /* "trade.pyx":857 * 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, 764, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_NotEnoughGoods); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 857, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 764, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 857, __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, 764, __pyx_L1_error) + __pyx_t_8 = PyFloat_FromDouble((__pyx_v_quantity - __pyx_v_available)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 857, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = NULL; __pyx_t_10 = 0; @@ -13038,7 +11958,7 @@ static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_sel #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, 764, __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, 857, __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; @@ -13048,7 +11968,7 @@ static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_sel #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, 764, __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, 857, __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; @@ -13056,7 +11976,7 @@ static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_sel } else #endif { - __pyx_t_11 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 764, __pyx_L1_error) + __pyx_t_11 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 857, __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; @@ -13070,16 +11990,16 @@ static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_sel 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, 764, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 857, __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, 764, __pyx_L1_error) + __PYX_ERR(0, 857, __pyx_L1_error) - /* "trade.pyx":763 + /* "trade.pyx":856 * quantity = 0 * available = self._inventory[good] * if quantity > available + epsilon + epsilon * max(quantity, available): # <<<<<<<<<<<<<< @@ -13088,7 +12008,7 @@ static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_sel */ } - /* "trade.pyx":765 + /* "trade.pyx":858 * if quantity > available + epsilon + epsilon * max(quantity, available): * raise NotEnoughGoods(self.name, good, quantity - available) * if quantity > available: # <<<<<<<<<<<<<< @@ -13098,7 +12018,7 @@ static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_sel __pyx_t_4 = ((__pyx_v_quantity > __pyx_v_available) != 0); if (__pyx_t_4) { - /* "trade.pyx":766 + /* "trade.pyx":859 * raise NotEnoughGoods(self.name, good, quantity - available) * if quantity > available: * quantity = available # <<<<<<<<<<<<<< @@ -13107,7 +12027,7 @@ static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_sel */ __pyx_v_quantity = __pyx_v_available; - /* "trade.pyx":765 + /* "trade.pyx":858 * if quantity > available + epsilon + epsilon * max(quantity, available): * raise NotEnoughGoods(self.name, good, quantity - available) * if quantity > available: # <<<<<<<<<<<<<< @@ -13116,45 +12036,45 @@ static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_sel */ } - /* "trade.pyx":767 + /* "trade.pyx":860 * if quantity > available: * quantity = available * self._inventory.haves[good] -= quantity # <<<<<<<<<<<<<< * self._send(receiver, 'abce_receive_good', [good, quantity]) * return {good: quantity} */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 767, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_inventory); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 860, __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, 767, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_haves); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 860, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_v_good); __pyx_t_3 = __pyx_v_good; - __pyx_t_11 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 767, __pyx_L1_error) + __pyx_t_11 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 860, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __pyx_t_8 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 767, __pyx_L1_error) + __pyx_t_8 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 860, __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, 767, __pyx_L1_error) + __pyx_t_1 = PyNumber_InPlaceSubtract(__pyx_t_11, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 860, __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_2, __pyx_t_3, __pyx_t_1) < 0)) __PYX_ERR(0, 767, __pyx_L1_error) + if (unlikely(PyObject_SetItem(__pyx_t_2, __pyx_t_3, __pyx_t_1) < 0)) __PYX_ERR(0, 860, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":768 + /* "trade.pyx":861 * quantity = available * self._inventory.haves[good] -= quantity * self._send(receiver, 'abce_receive_good', [good, quantity]) # <<<<<<<<<<<<<< * return {good: quantity} * */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_send); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 768, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_send); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 861, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 768, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 861, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyList_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 768, __pyx_L1_error) + __pyx_t_8 = PyList_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 861, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_v_good); __Pyx_GIVEREF(__pyx_v_good); @@ -13177,7 +12097,7 @@ static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_sel #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_v_receiver, __pyx_n_s_abce_receive_good, __pyx_t_8}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 768, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 861, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; @@ -13186,14 +12106,14 @@ static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_sel #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_v_receiver, __pyx_n_s_abce_receive_good, __pyx_t_8}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 768, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 861, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { - __pyx_t_11 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 768, __pyx_L1_error) + __pyx_t_11 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 861, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (__pyx_t_1) { __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); __pyx_t_1 = NULL; @@ -13207,14 +12127,14 @@ static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_sel __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_t_8); __pyx_t_8 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 768, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 861, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":769 + /* "trade.pyx":862 * self._inventory.haves[good] -= quantity * self._send(receiver, 'abce_receive_good', [good, quantity]) * return {good: quantity} # <<<<<<<<<<<<<< @@ -13222,17 +12142,17 @@ static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_sel * def take(self, receiver, good, double quantity, double epsilon=epsilon): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 769, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 862, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 769, __pyx_L1_error) + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 862, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_2, __pyx_v_good, __pyx_t_3) < 0) __PYX_ERR(0, 769, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_2, __pyx_v_good, __pyx_t_3) < 0) __PYX_ERR(0, 862, __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":729 + /* "trade.pyx":822 * self._inventory.rewind(offer.currency, offer.quantity * offer.price) * * def give(self, receiver, good, double quantity, double epsilon=epsilon): # <<<<<<<<<<<<<< @@ -13256,7 +12176,7 @@ static PyObject *__pyx_pf_5trade_5Trade_50give(CYTHON_UNUSED PyObject *__pyx_sel return __pyx_r; } -/* "trade.pyx":771 +/* "trade.pyx":864 * return {good: quantity} * * def take(self, receiver, good, double quantity, double epsilon=epsilon): # <<<<<<<<<<<<<< @@ -13271,14 +12191,14 @@ static PyObject *__pyx_pf_5trade_12__defaults__(CYTHON_UNUSED PyObject *__pyx_se PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("__defaults__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(__Pyx_CyFunction_Defaults(__pyx_defaults4, __pyx_self)->__pyx_arg_epsilon); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 771, __pyx_L1_error) + __pyx_t_1 = PyFloat_FromDouble(__Pyx_CyFunction_Defaults(__pyx_defaults4, __pyx_self)->__pyx_arg_epsilon); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 864, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 771, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 864, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 771, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 864, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); @@ -13303,10 +12223,10 @@ static PyObject *__pyx_pf_5trade_12__defaults__(CYTHON_UNUSED PyObject *__pyx_se } /* Python wrapper */ -static PyObject *__pyx_pw_5trade_5Trade_53take(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_5trade_5Trade_52take[] = " take a good from another agent. The other agent has to accept.\n using self.accept()\n\n Args:\n\n\n receiver_group:\n group of the receiving agent\n\n receiver_id:\n number of the receiving agent\n\n good:\n the good to be taken\n\n quantity:\n the quantity to be taken\n\n epsilon (optional):\n if you have floating point errors, a quantity or prices is\n a fraction of number to high or low. You can increase the\n floating point tolerance. See troubleshooting -- floating point problems\n "; -static PyMethodDef __pyx_mdef_5trade_5Trade_53take = {"take", (PyCFunction)__pyx_pw_5trade_5Trade_53take, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_52take}; -static PyObject *__pyx_pw_5trade_5Trade_53take(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5trade_5Trade_47take(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5trade_5Trade_46take[] = " take a good from another agent. The other agent has to accept.\n using self.accept()\n\n Args:\n\n\n receiver_group:\n group of the receiving agent\n\n receiver_id:\n number of the receiving agent\n\n good:\n the good to be taken\n\n quantity:\n the quantity to be taken\n\n epsilon (optional):\n if you have floating point errors, a quantity or prices is\n a fraction of number to high or low. You can increase the\n floating point tolerance. See troubleshooting -- floating point problems\n "; +static PyMethodDef __pyx_mdef_5trade_5Trade_47take = {"take", (PyCFunction)__pyx_pw_5trade_5Trade_47take, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5trade_5Trade_46take}; +static PyObject *__pyx_pw_5trade_5Trade_47take(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_receiver = 0; PyObject *__pyx_v_good = 0; @@ -13345,19 +12265,19 @@ static PyObject *__pyx_pw_5trade_5Trade_53take(PyObject *__pyx_self, PyObject *_ case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_receiver)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("take", 0, 4, 5, 1); __PYX_ERR(0, 771, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("take", 0, 4, 5, 1); __PYX_ERR(0, 864, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_good)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("take", 0, 4, 5, 2); __PYX_ERR(0, 771, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("take", 0, 4, 5, 2); __PYX_ERR(0, 864, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_quantity)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("take", 0, 4, 5, 3); __PYX_ERR(0, 771, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("take", 0, 4, 5, 3); __PYX_ERR(0, 864, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: @@ -13367,7 +12287,7 @@ static PyObject *__pyx_pw_5trade_5Trade_53take(PyObject *__pyx_self, PyObject *_ } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "take") < 0)) __PYX_ERR(0, 771, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "take") < 0)) __PYX_ERR(0, 864, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -13384,29 +12304,29 @@ static PyObject *__pyx_pw_5trade_5Trade_53take(PyObject *__pyx_self, PyObject *_ __pyx_v_self = values[0]; __pyx_v_receiver = values[1]; __pyx_v_good = values[2]; - __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 771, __pyx_L3_error) + __pyx_v_quantity = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_quantity == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 864, __pyx_L3_error) if (values[4]) { - __pyx_v_epsilon = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_epsilon == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 771, __pyx_L3_error) + __pyx_v_epsilon = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_epsilon == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 864, __pyx_L3_error) } else { __pyx_v_epsilon = __pyx_dynamic_args->__pyx_arg_epsilon; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("take", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 771, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("take", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 864, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("trade.Trade.take", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5trade_5Trade_52take(__pyx_self, __pyx_v_self, __pyx_v_receiver, __pyx_v_good, __pyx_v_quantity, __pyx_v_epsilon); + __pyx_r = __pyx_pf_5trade_5Trade_46take(__pyx_self, __pyx_v_self, __pyx_v_receiver, __pyx_v_good, __pyx_v_quantity, __pyx_v_epsilon); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_5trade_5Trade_52take(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_receiver, PyObject *__pyx_v_good, double __pyx_v_quantity, double __pyx_v_epsilon) { +static PyObject *__pyx_pf_5trade_5Trade_46take(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_receiver, PyObject *__pyx_v_good, double __pyx_v_quantity, double __pyx_v_epsilon) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -13415,40 +12335,40 @@ static PyObject *__pyx_pf_5trade_5Trade_52take(CYTHON_UNUSED PyObject *__pyx_sel PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("take", 0); - /* "trade.pyx":795 + /* "trade.pyx":888 * floating point tolerance. See troubleshooting -- floating point problems * """ - * self.buy(receiver, good=good, quantity=quantity, price=0, epsilon=epsilon) # <<<<<<<<<<<<<< - * + * self.make_bid(receiver, good=good, quantity=quantity, price=0, epsilon=epsilon) # <<<<<<<<<<<<<< * + * def get_take(self, *args, **kwargs): */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_buy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 795, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_make_bid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 888, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 795, __pyx_L1_error) + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 888, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_receiver); __Pyx_GIVEREF(__pyx_v_receiver); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_receiver); - __pyx_t_3 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 795, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 888, __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, 795, __pyx_L1_error) - __pyx_t_4 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 795, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_good, __pyx_v_good) < 0) __PYX_ERR(0, 888, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_quantity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 888, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_quantity, __pyx_t_4) < 0) __PYX_ERR(0, 795, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_quantity, __pyx_t_4) < 0) __PYX_ERR(0, 888, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_price, __pyx_int_0) < 0) __PYX_ERR(0, 795, __pyx_L1_error) - __pyx_t_4 = PyFloat_FromDouble(__pyx_v_epsilon); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 795, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_price, __pyx_int_0) < 0) __PYX_ERR(0, 888, __pyx_L1_error) + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_epsilon); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 888, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_epsilon, __pyx_t_4) < 0) __PYX_ERR(0, 795, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_epsilon, __pyx_t_4) < 0) __PYX_ERR(0, 888, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 795, __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, 888, __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; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "trade.pyx":771 + /* "trade.pyx":864 * return {good: quantity} * * def take(self, receiver, good, double quantity, double epsilon=epsilon): # <<<<<<<<<<<<<< @@ -13472,7 +12392,130 @@ static PyObject *__pyx_pf_5trade_5Trade_52take(CYTHON_UNUSED PyObject *__pyx_sel return __pyx_r; } -/* "trade.pyx":799 +/* "trade.pyx":890 + * self.make_bid(receiver, good=good, quantity=quantity, price=0, epsilon=epsilon) + * + * def get_take(self, *args, **kwargs): # <<<<<<<<<<<<<< + * return self.get_bids(*args, **kwargs) + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_5trade_5Trade_49get_take(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_5trade_5Trade_49get_take = {"get_take", (PyCFunction)__pyx_pw_5trade_5Trade_49get_take, METH_VARARGS|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_5trade_5Trade_49get_take(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_self = 0; + PyObject *__pyx_v_args = 0; + PyObject *__pyx_v_kwargs = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_take (wrapper)", 0); + __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL; + __Pyx_GOTREF(__pyx_v_kwargs); + if (PyTuple_GET_SIZE(__pyx_args) > 1) { + __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); + if (unlikely(!__pyx_v_args)) { + __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0; + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_v_args); + } else { + __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple); + } + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,0}; + PyObject* values[1] = {0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + default: + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (unlikely(kw_args > 0)) { + const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1; + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, used_pos_args, "get_take") < 0)) __PYX_ERR(0, 890, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) < 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_self = values[0]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("get_take", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 890, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; + __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0; + __Pyx_AddTraceback("trade.Trade.get_take", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_5trade_5Trade_48get_take(__pyx_self, __pyx_v_self, __pyx_v_args, __pyx_v_kwargs); + + /* function exit code */ + __Pyx_XDECREF(__pyx_v_args); + __Pyx_XDECREF(__pyx_v_kwargs); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_5trade_5Trade_48get_take(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("get_take", 0); + + /* "trade.pyx":891 + * + * def get_take(self, *args, **kwargs): + * return self.get_bids(*args, **kwargs) # <<<<<<<<<<<<<< + * + * # TODO when cython supports function overloading overload this function with compare_with_ties(int x, int y) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_get_bids); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 891, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_v_args, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 891, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "trade.pyx":890 + * self.make_bid(receiver, good=good, quantity=quantity, price=0, epsilon=epsilon) + * + * def get_take(self, *args, **kwargs): # <<<<<<<<<<<<<< + * return self.get_bids(*args, **kwargs) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("trade.Trade.get_take", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "trade.pyx":894 * * # 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): # <<<<<<<<<<<<<< @@ -13489,7 +12532,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":800 + /* "trade.pyx":895 * # 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: # <<<<<<<<<<<<<< @@ -13499,7 +12542,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":801 + /* "trade.pyx":896 * cdef int compare_with_ties(double x, double y): * if x < y: * return -1 # <<<<<<<<<<<<<< @@ -13509,7 +12552,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":800 + /* "trade.pyx":895 * # 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: # <<<<<<<<<<<<<< @@ -13518,7 +12561,7 @@ static int __pyx_f_5trade_compare_with_ties(double __pyx_v_x, double __pyx_v_y) */ } - /* "trade.pyx":802 + /* "trade.pyx":897 * if x < y: * return -1 * elif x > y: # <<<<<<<<<<<<<< @@ -13528,7 +12571,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":803 + /* "trade.pyx":898 * return -1 * elif x > y: * return 1 # <<<<<<<<<<<<<< @@ -13538,7 +12581,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":802 + /* "trade.pyx":897 * if x < y: * return -1 * elif x > y: # <<<<<<<<<<<<<< @@ -13547,34 +12590,34 @@ static int __pyx_f_5trade_compare_with_ties(double __pyx_v_x, double __pyx_v_y) */ } - /* "trade.pyx":805 + /* "trade.pyx":900 * 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, 805, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 900, __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, 805, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_randint); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 900, __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_, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 805, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 900, __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, 805, __pyx_L1_error) + __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_int_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 900, __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, 805, __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, 900, __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, 805, __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, 900, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_4; goto __pyx_L0; } - /* "trade.pyx":799 + /* "trade.pyx":894 * * # 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): # <<<<<<<<<<<<<< @@ -13878,25 +12921,21 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_Trade__reject, __pyx_k_Trade__reject, sizeof(__pyx_k_Trade__reject), 0, 0, 1, 1}, {&__pyx_n_s_Trade__reject_polled_but_not_acc, __pyx_k_Trade__reject_polled_but_not_acc, sizeof(__pyx_k_Trade__reject_polled_but_not_acc), 0, 0, 1, 1}, {&__pyx_n_s_Trade_accept, __pyx_k_Trade_accept, sizeof(__pyx_k_Trade_accept), 0, 0, 1, 1}, - {&__pyx_n_s_Trade_buy, __pyx_k_Trade_buy, sizeof(__pyx_k_Trade_buy), 0, 0, 1, 1}, - {&__pyx_n_s_Trade_get_buy_offers, __pyx_k_Trade_get_buy_offers, sizeof(__pyx_k_Trade_get_buy_offers), 0, 0, 1, 1}, - {&__pyx_n_s_Trade_get_buy_offers_all, __pyx_k_Trade_get_buy_offers_all, sizeof(__pyx_k_Trade_get_buy_offers_all), 0, 0, 1, 1}, - {&__pyx_n_s_Trade_get_buy_offers_locals_lamb, __pyx_k_Trade_get_buy_offers_locals_lamb, sizeof(__pyx_k_Trade_get_buy_offers_locals_lamb), 0, 0, 1, 1}, + {&__pyx_n_s_Trade_get_bids, __pyx_k_Trade_get_bids, sizeof(__pyx_k_Trade_get_bids), 0, 0, 1, 1}, + {&__pyx_n_s_Trade_get_bids_all, __pyx_k_Trade_get_bids_all, sizeof(__pyx_k_Trade_get_bids_all), 0, 0, 1, 1}, + {&__pyx_n_s_Trade_get_bids_locals_lambda, __pyx_k_Trade_get_bids_locals_lambda, sizeof(__pyx_k_Trade_get_bids_locals_lambda), 0, 0, 1, 1}, {&__pyx_n_s_Trade_get_offers, __pyx_k_Trade_get_offers, sizeof(__pyx_k_Trade_get_offers), 0, 0, 1, 1}, {&__pyx_n_s_Trade_get_offers_all, __pyx_k_Trade_get_offers_all, sizeof(__pyx_k_Trade_get_offers_all), 0, 0, 1, 1}, {&__pyx_n_s_Trade_get_offers_locals_lambda, __pyx_k_Trade_get_offers_locals_lambda, sizeof(__pyx_k_Trade_get_offers_locals_lambda), 0, 0, 1, 1}, - {&__pyx_n_s_Trade_get_sell_offers, __pyx_k_Trade_get_sell_offers, sizeof(__pyx_k_Trade_get_sell_offers), 0, 0, 1, 1}, - {&__pyx_n_s_Trade_get_sell_offers_all, __pyx_k_Trade_get_sell_offers_all, sizeof(__pyx_k_Trade_get_sell_offers_all), 0, 0, 1, 1}, - {&__pyx_n_s_Trade_get_sell_offers_locals_lam, __pyx_k_Trade_get_sell_offers_locals_lam, sizeof(__pyx_k_Trade_get_sell_offers_locals_lam), 0, 0, 1, 1}, + {&__pyx_n_s_Trade_get_take, __pyx_k_Trade_get_take, sizeof(__pyx_k_Trade_get_take), 0, 0, 1, 1}, {&__pyx_n_s_Trade_give, __pyx_k_Trade_give, sizeof(__pyx_k_Trade_give), 0, 0, 1, 1}, - {&__pyx_n_s_Trade_peak_buy_offers, __pyx_k_Trade_peak_buy_offers, sizeof(__pyx_k_Trade_peak_buy_offers), 0, 0, 1, 1}, - {&__pyx_n_s_Trade_peak_buy_offers_locals_lam, __pyx_k_Trade_peak_buy_offers_locals_lam, sizeof(__pyx_k_Trade_peak_buy_offers_locals_lam), 0, 0, 1, 1}, + {&__pyx_n_s_Trade_make_bid, __pyx_k_Trade_make_bid, sizeof(__pyx_k_Trade_make_bid), 0, 0, 1, 1}, + {&__pyx_n_s_Trade_make_offer, __pyx_k_Trade_make_offer, sizeof(__pyx_k_Trade_make_offer), 0, 0, 1, 1}, + {&__pyx_n_s_Trade_peak_bids, __pyx_k_Trade_peak_bids, sizeof(__pyx_k_Trade_peak_bids), 0, 0, 1, 1}, + {&__pyx_n_s_Trade_peak_bids_locals_lambda, __pyx_k_Trade_peak_bids_locals_lambda, sizeof(__pyx_k_Trade_peak_bids_locals_lambda), 0, 0, 1, 1}, {&__pyx_n_s_Trade_peak_offers, __pyx_k_Trade_peak_offers, sizeof(__pyx_k_Trade_peak_offers), 0, 0, 1, 1}, {&__pyx_n_s_Trade_peak_offers_locals_lambda, __pyx_k_Trade_peak_offers_locals_lambda, sizeof(__pyx_k_Trade_peak_offers_locals_lambda), 0, 0, 1, 1}, - {&__pyx_n_s_Trade_peak_sell_offers, __pyx_k_Trade_peak_sell_offers, sizeof(__pyx_k_Trade_peak_sell_offers), 0, 0, 1, 1}, - {&__pyx_n_s_Trade_peak_sell_offers_locals_la, __pyx_k_Trade_peak_sell_offers_locals_la, sizeof(__pyx_k_Trade_peak_sell_offers_locals_la), 0, 0, 1, 1}, {&__pyx_n_s_Trade_reject, __pyx_k_Trade_reject, sizeof(__pyx_k_Trade_reject), 0, 0, 1, 1}, - {&__pyx_n_s_Trade_sell, __pyx_k_Trade_sell, sizeof(__pyx_k_Trade_sell), 0, 0, 1, 1}, {&__pyx_n_s_Trade_take, __pyx_k_Trade_take, sizeof(__pyx_k_Trade_take), 0, 0, 1, 1}, {&__pyx_n_s_abce_notenoughgoods, __pyx_k_abce_notenoughgoods, sizeof(__pyx_k_abce_notenoughgoods), 0, 0, 1, 1}, {&__pyx_n_s_abce_propose_buy, __pyx_k_abce_propose_buy, sizeof(__pyx_k_abce_propose_buy), 0, 0, 1, 1}, @@ -13909,8 +12948,8 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_accepted_more_than_offered_s_100, __pyx_k_accepted_more_than_offered_s_100, sizeof(__pyx_k_accepted_more_than_offered_s_100), 0, 0, 1, 0}, {&__pyx_n_s_advance_round, __pyx_k_advance_round, sizeof(__pyx_k_advance_round), 0, 0, 1, 1}, {&__pyx_n_s_agent_parameters, __pyx_k_agent_parameters, sizeof(__pyx_k_agent_parameters), 0, 0, 1, 1}, + {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1}, {&__pyx_n_s_available, __pyx_k_available, sizeof(__pyx_k_available), 0, 0, 1, 1}, - {&__pyx_n_s_buy, __pyx_k_buy, sizeof(__pyx_k_buy), 0, 0, 1, 1}, {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, {&__pyx_n_s_collections, __pyx_k_collections, sizeof(__pyx_k_collections), 0, 0, 1, 1}, {&__pyx_n_s_commit, __pyx_k_commit, sizeof(__pyx_k_commit), 0, 0, 1, 1}, @@ -13922,13 +12961,12 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1}, {&__pyx_n_s_epsilon, __pyx_k_epsilon, sizeof(__pyx_k_epsilon), 0, 0, 1, 1}, {&__pyx_n_s_final_quantity, __pyx_k_final_quantity, sizeof(__pyx_k_final_quantity), 0, 0, 1, 1}, - {&__pyx_n_s_get_buy_offers, __pyx_k_get_buy_offers, sizeof(__pyx_k_get_buy_offers), 0, 0, 1, 1}, - {&__pyx_n_s_get_buy_offers_all, __pyx_k_get_buy_offers_all, sizeof(__pyx_k_get_buy_offers_all), 0, 0, 1, 1}, + {&__pyx_n_s_get_bids, __pyx_k_get_bids, sizeof(__pyx_k_get_bids), 0, 0, 1, 1}, + {&__pyx_n_s_get_bids_all, __pyx_k_get_bids_all, sizeof(__pyx_k_get_bids_all), 0, 0, 1, 1}, {&__pyx_n_s_get_epsilon, __pyx_k_get_epsilon, sizeof(__pyx_k_get_epsilon), 0, 0, 1, 1}, {&__pyx_n_s_get_offers, __pyx_k_get_offers, sizeof(__pyx_k_get_offers), 0, 0, 1, 1}, {&__pyx_n_s_get_offers_all, __pyx_k_get_offers_all, sizeof(__pyx_k_get_offers_all), 0, 0, 1, 1}, - {&__pyx_n_s_get_sell_offers, __pyx_k_get_sell_offers, sizeof(__pyx_k_get_sell_offers), 0, 0, 1, 1}, - {&__pyx_n_s_get_sell_offers_all, __pyx_k_get_sell_offers_all, sizeof(__pyx_k_get_sell_offers_all), 0, 0, 1, 1}, + {&__pyx_n_s_get_take, __pyx_k_get_take, sizeof(__pyx_k_get_take), 0, 0, 1, 1}, {&__pyx_n_s_give, __pyx_k_give, sizeof(__pyx_k_give), 0, 0, 1, 1}, {&__pyx_n_s_given_offers, __pyx_k_given_offers, sizeof(__pyx_k_given_offers), 0, 0, 1, 1}, {&__pyx_n_s_good, __pyx_k_good, sizeof(__pyx_k_good), 0, 0, 1, 1}, @@ -13942,10 +12980,13 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__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_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 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}, {&__pyx_n_s_log_receive_accept_group, __pyx_k_log_receive_accept_group, sizeof(__pyx_k_log_receive_accept_group), 0, 0, 1, 1}, {&__pyx_n_s_made, __pyx_k_made, sizeof(__pyx_k_made), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_make_bid, __pyx_k_make_bid, sizeof(__pyx_k_make_bid), 0, 0, 1, 1}, + {&__pyx_n_s_make_offer, __pyx_k_make_offer, sizeof(__pyx_k_make_offer), 0, 0, 1, 1}, {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1}, {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1}, {&__pyx_n_s_money, __pyx_k_money, sizeof(__pyx_k_money), 0, 0, 1, 1}, @@ -13963,9 +13004,8 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_offer_quantity, __pyx_k_offer_quantity, sizeof(__pyx_k_offer_quantity), 0, 0, 1, 1}, {&__pyx_n_s_open_offers_buy, __pyx_k_open_offers_buy, sizeof(__pyx_k_open_offers_buy), 0, 0, 1, 1}, {&__pyx_n_s_open_offers_sell, __pyx_k_open_offers_sell, sizeof(__pyx_k_open_offers_sell), 0, 0, 1, 1}, - {&__pyx_n_s_peak_buy_offers, __pyx_k_peak_buy_offers, sizeof(__pyx_k_peak_buy_offers), 0, 0, 1, 1}, + {&__pyx_n_s_peak_bids, __pyx_k_peak_bids, sizeof(__pyx_k_peak_bids), 0, 0, 1, 1}, {&__pyx_n_s_peak_offers, __pyx_k_peak_offers, sizeof(__pyx_k_peak_offers), 0, 0, 1, 1}, - {&__pyx_n_s_peak_sell_offers, __pyx_k_peak_sell_offers, sizeof(__pyx_k_peak_sell_offers), 0, 0, 1, 1}, {&__pyx_n_s_polled_offers, __pyx_k_polled_offers, sizeof(__pyx_k_polled_offers), 0, 0, 1, 1}, {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1}, {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1}, @@ -14021,7 +13061,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { }; static int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(0, 227, __pyx_L1_error) - __pyx_builtin_AssertionError = __Pyx_GetBuiltinName(__pyx_n_s_AssertionError); if (!__pyx_builtin_AssertionError) __PYX_ERR(0, 593, __pyx_L1_error) + __pyx_builtin_AssertionError = __Pyx_GetBuiltinName(__pyx_n_s_AssertionError); if (!__pyx_builtin_AssertionError) __PYX_ERR(0, 686, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; @@ -14031,13 +13071,13 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "trade.pyx":805 + /* "trade.pyx":900 * return 1 * else: * return random.randint(0, 1) * 2 - 1 # <<<<<<<<<<<<<< * */ - __pyx_tuple_ = PyTuple_Pack(2, __pyx_int_0, __pyx_int_1); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 805, __pyx_L1_error) + __pyx_tuple_ = PyTuple_Pack(2, __pyx_int_0, __pyx_int_1); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 900, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); @@ -14101,317 +13141,284 @@ static int __Pyx_InitCachedConstants(void) { /* "trade.pyx":252 * self._trade_log = defaultdict(int) * - * 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} + * def get_bids_all(self, descending=True, sorted=True): # <<<<<<<<<<<<<< + * """ returns all bids in a dictionary, with goods as key. The in each + * goods-category the goods are ordered by price. The order can be reversed */ __pyx_tuple__11 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_descending, __pyx_n_s_sorted, __pyx_n_s_goods, __pyx_n_s_good); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__11); __Pyx_GIVEREF(__pyx_tuple__11); - __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_get_buy_offers_all, 252, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 252, __pyx_L1_error) - __pyx_tuple__13 = PyTuple_Pack(2, ((PyObject *)Py_False), ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 252, __pyx_L1_error) + __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_get_bids_all, 252, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 252, __pyx_L1_error) + __pyx_tuple__13 = PyTuple_Pack(2, ((PyObject *)Py_True), ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__13); __Pyx_GIVEREF(__pyx_tuple__13); - /* "trade.pyx":256 + /* "trade.pyx":289 * return {good: self.get_offers(good, descending, sorted) for good in goods} * - * 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} + * def get_offers_all(self, descending=False, sorted=True): # <<<<<<<<<<<<<< + * """ returns all offers in a dictionary, with goods as key. The in each + * goods-category the goods are ordered by price. The order can be reversed */ - __pyx_tuple__14 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_descending, __pyx_n_s_sorted, __pyx_n_s_goods, __pyx_n_s_good); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 256, __pyx_L1_error) + __pyx_tuple__14 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_descending, __pyx_n_s_sorted, __pyx_n_s_goods, __pyx_n_s_good); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__14); __Pyx_GIVEREF(__pyx_tuple__14); - __pyx_codeobj__15 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__14, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_get_sell_offers_all, 256, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__15)) __PYX_ERR(0, 256, __pyx_L1_error) - __pyx_tuple__16 = PyTuple_Pack(2, ((PyObject *)Py_False), ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 256, __pyx_L1_error) + __pyx_codeobj__15 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__14, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_get_offers_all, 289, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__15)) __PYX_ERR(0, 289, __pyx_L1_error) + __pyx_tuple__16 = PyTuple_Pack(2, ((PyObject *)Py_False), ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__16); __Pyx_GIVEREF(__pyx_tuple__16); - /* "trade.pyx":260 + /* "trade.pyx":326 * return {good: self.get_offers(good, descending, sorted) for good in goods} * - * def get_offers_all(self, descending=False, sorted=True): # <<<<<<<<<<<<<< - * """ returns all offers in a dictionary, with goods as key. The in each - * goods-category the goods are ordered by price. The order can be reversed + * def get_bids(self, good, sorted=True, descending=True, shuffled=True): # <<<<<<<<<<<<<< + * """ returns all bids of the 'good' ordered by price. + * */ - __pyx_tuple__17 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_descending, __pyx_n_s_sorted, __pyx_n_s_goods, __pyx_n_s_good); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 260, __pyx_L1_error) + __pyx_tuple__17 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_good, __pyx_n_s_sorted, __pyx_n_s_descending, __pyx_n_s_shuffled, __pyx_n_s_ret); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 326, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__17); __Pyx_GIVEREF(__pyx_tuple__17); - __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_get_offers_all, 260, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 260, __pyx_L1_error) - __pyx_tuple__19 = PyTuple_Pack(2, ((PyObject *)Py_False), ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 260, __pyx_L1_error) + __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(5, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_get_bids, 326, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 326, __pyx_L1_error) + __pyx_tuple__19 = PyTuple_Pack(3, ((PyObject *)Py_True), ((PyObject *)Py_True), ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 326, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__19); __Pyx_GIVEREF(__pyx_tuple__19); - /* "trade.pyx":297 - * return {good: self.get_offers(good, descending, sorted) for good in goods} + /* "trade.pyx":373 + * return ret + * + * def get_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< + * """ returns all offers of the 'good' ordered by price. * - * 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]) */ - __pyx_tuple__20 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_good, __pyx_n_s_sorted, __pyx_n_s_descending, __pyx_n_s_shuffled, __pyx_n_s_ret); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 297, __pyx_L1_error) + __pyx_tuple__20 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_good, __pyx_n_s_sorted, __pyx_n_s_descending, __pyx_n_s_shuffled, __pyx_n_s_ret); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 373, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__20); __Pyx_GIVEREF(__pyx_tuple__20); - __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(5, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_get_buy_offers, 297, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 297, __pyx_L1_error) - __pyx_tuple__22 = PyTuple_Pack(3, ((PyObject *)Py_True), ((PyObject *)Py_False), ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 297, __pyx_L1_error) + __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(5, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_get_offers, 373, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 373, __pyx_L1_error) + __pyx_tuple__22 = PyTuple_Pack(3, ((PyObject *)Py_True), ((PyObject *)Py_False), ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 373, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__22); __Pyx_GIVEREF(__pyx_tuple__22); - /* "trade.pyx":307 - * return ret + /* "trade.pyx":421 * - * 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]) + * + * def peak_bids(self, good, sorted=True, descending=True, shuffled=True): # <<<<<<<<<<<<<< + * """ returns a peak on all bids for the 'good' ordered by price. + * Peaked bids can not be accepted or rejected and they do not */ - __pyx_tuple__23 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_good, __pyx_n_s_sorted, __pyx_n_s_descending, __pyx_n_s_shuffled, __pyx_n_s_ret); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 307, __pyx_L1_error) + __pyx_tuple__23 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_good, __pyx_n_s_sorted, __pyx_n_s_descending, __pyx_n_s_shuffled, __pyx_n_s_ret, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__23); __Pyx_GIVEREF(__pyx_tuple__23); - __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(5, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_get_sell_offers, 307, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 307, __pyx_L1_error) - __pyx_tuple__25 = PyTuple_Pack(3, ((PyObject *)Py_True), ((PyObject *)Py_False), ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 307, __pyx_L1_error) + __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(5, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_peak_bids, 421, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 421, __pyx_L1_error) + __pyx_tuple__25 = PyTuple_Pack(3, ((PyObject *)Py_True), ((PyObject *)Py_True), ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__25); __Pyx_GIVEREF(__pyx_tuple__25); - /* "trade.pyx":317 + /* "trade.pyx":464 * return ret * - * def get_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< - * """ returns all offers of the 'good' ordered by price. - * + * def peak_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< + * """ returns a peak on all offers of the 'good' ordered by price. + * Peaked offers can not be accepted or rejected and they do not */ - __pyx_tuple__26 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_good, __pyx_n_s_sorted, __pyx_n_s_descending, __pyx_n_s_shuffled, __pyx_n_s_ret); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 317, __pyx_L1_error) + __pyx_tuple__26 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_good, __pyx_n_s_sorted, __pyx_n_s_descending, __pyx_n_s_shuffled, __pyx_n_s_ret, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 464, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__26); __Pyx_GIVEREF(__pyx_tuple__26); - __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(5, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_get_offers, 317, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 317, __pyx_L1_error) - __pyx_tuple__28 = PyTuple_Pack(3, ((PyObject *)Py_True), ((PyObject *)Py_False), ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 317, __pyx_L1_error) + __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(5, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_peak_offers, 464, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 464, __pyx_L1_error) + __pyx_tuple__28 = PyTuple_Pack(3, ((PyObject *)Py_True), ((PyObject *)Py_False), ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 464, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__28); __Pyx_GIVEREF(__pyx_tuple__28); - /* "trade.pyx":363 + /* "trade.pyx":509 * return ret * - * def peak_buy_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< - * ret = [] - * for offer in self._open_offers_buy[good].values(): + * def make_offer(self, receiver, # <<<<<<<<<<<<<< + * good, double quantity, double price, str currency='money', double epsilon=epsilon): + * """ commits to sell the quantity of good at price */ - __pyx_tuple__29 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_good, __pyx_n_s_sorted, __pyx_n_s_descending, __pyx_n_s_shuffled, __pyx_n_s_ret, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 363, __pyx_L1_error) + __pyx_tuple__29 = PyTuple_Pack(10, __pyx_n_s_self, __pyx_n_s_receiver, __pyx_n_s_good, __pyx_n_s_quantity, __pyx_n_s_price, __pyx_n_s_currency, __pyx_n_s_epsilon, __pyx_n_s_available, __pyx_n_s_offer_id, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__29); __Pyx_GIVEREF(__pyx_tuple__29); - __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(5, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_peak_buy_offers, 363, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 363, __pyx_L1_error) - __pyx_tuple__31 = PyTuple_Pack(3, ((PyObject *)Py_True), ((PyObject *)Py_False), ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 363, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__31); - __Pyx_GIVEREF(__pyx_tuple__31); - - /* "trade.pyx":373 - * return ret - * - * def peak_sell_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< - * ret = [] - * for offer in self._open_offers_sell[good].values(): - */ - __pyx_tuple__32 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_good, __pyx_n_s_sorted, __pyx_n_s_descending, __pyx_n_s_shuffled, __pyx_n_s_ret, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 373, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__32); - __Pyx_GIVEREF(__pyx_tuple__32); - __pyx_codeobj__33 = (PyObject*)__Pyx_PyCode_New(5, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__32, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_peak_sell_offers, 373, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__33)) __PYX_ERR(0, 373, __pyx_L1_error) - __pyx_tuple__34 = PyTuple_Pack(3, ((PyObject *)Py_True), ((PyObject *)Py_False), ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 373, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__34); - __Pyx_GIVEREF(__pyx_tuple__34); - - /* "trade.pyx":383 - * return ret - * - * def peak_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< - * """ returns a peak on all offers of the 'good' ordered by price. - * Peaked offers can not be accepted or rejected and they do not - */ - __pyx_tuple__35 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_good, __pyx_n_s_sorted, __pyx_n_s_descending, __pyx_n_s_shuffled, __pyx_n_s_ret); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 383, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__35); - __Pyx_GIVEREF(__pyx_tuple__35); - __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(5, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_peak_offers, 383, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 383, __pyx_L1_error) - __pyx_tuple__37 = PyTuple_Pack(3, ((PyObject *)Py_True), ((PyObject *)Py_False), ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 383, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__37); - __Pyx_GIVEREF(__pyx_tuple__37); - - /* "trade.pyx":416 - * return ret - * - * def sell(self, receiver, # <<<<<<<<<<<<<< - * good, double quantity, double price, str currency='money', double epsilon=epsilon): - * """ commits to sell the quantity of good at price - */ - __pyx_tuple__38 = PyTuple_Pack(10, __pyx_n_s_self, __pyx_n_s_receiver, __pyx_n_s_good, __pyx_n_s_quantity, __pyx_n_s_price, __pyx_n_s_currency, __pyx_n_s_epsilon, __pyx_n_s_available, __pyx_n_s_offer_id, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 416, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__38); - __Pyx_GIVEREF(__pyx_tuple__38); - __pyx_codeobj__39 = (PyObject*)__Pyx_PyCode_New(7, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__38, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_sell, 416, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) __PYX_ERR(0, 416, __pyx_L1_error) + __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(7, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_make_offer, 509, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 509, __pyx_L1_error) - /* "trade.pyx":499 + /* "trade.pyx":592 * return offer * - * def buy(self, receiver, good, # <<<<<<<<<<<<<< + * def make_bid(self, receiver, good, # <<<<<<<<<<<<<< * double quantity, double price, str currency='money', double epsilon=epsilon): * """ commits to sell the quantity of good at price */ - __pyx_tuple__40 = PyTuple_Pack(11, __pyx_n_s_self, __pyx_n_s_receiver, __pyx_n_s_good, __pyx_n_s_quantity, __pyx_n_s_price, __pyx_n_s_currency, __pyx_n_s_epsilon, __pyx_n_s_available, __pyx_n_s_money_amount, __pyx_n_s_offer_id, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 499, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__40); - __Pyx_GIVEREF(__pyx_tuple__40); - __pyx_codeobj__41 = (PyObject*)__Pyx_PyCode_New(7, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__40, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_buy, 499, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__41)) __PYX_ERR(0, 499, __pyx_L1_error) + __pyx_tuple__31 = PyTuple_Pack(11, __pyx_n_s_self, __pyx_n_s_receiver, __pyx_n_s_good, __pyx_n_s_quantity, __pyx_n_s_price, __pyx_n_s_currency, __pyx_n_s_epsilon, __pyx_n_s_available, __pyx_n_s_money_amount, __pyx_n_s_offer_id, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 592, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__31); + __Pyx_GIVEREF(__pyx_tuple__31); + __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(7, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_make_bid, 592, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 592, __pyx_L1_error) - /* "trade.pyx":563 + /* "trade.pyx":656 * 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 + * """ The offer or bid is accepted and cleared. If no quantity is + * given the offer/bid is fully accepted; If a quantity is given the offer/bid is */ - __pyx_tuple__42 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_offer, __pyx_n_s_quantity, __pyx_n_s_epsilon, __pyx_n_s_money_amount, __pyx_n_s_offer_quantity, __pyx_n_s_available); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 563, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__42); - __Pyx_GIVEREF(__pyx_tuple__42); - __pyx_codeobj__43 = (PyObject*)__Pyx_PyCode_New(4, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_accept, 563, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__43)) __PYX_ERR(0, 563, __pyx_L1_error) + __pyx_tuple__33 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_offer, __pyx_n_s_quantity, __pyx_n_s_epsilon, __pyx_n_s_money_amount, __pyx_n_s_offer_quantity, __pyx_n_s_available); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 656, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__33); + __Pyx_GIVEREF(__pyx_tuple__33); + __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(4, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_accept, 656, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 656, __pyx_L1_error) - /* "trade.pyx":634 + /* "trade.pyx":727 * return {offer.good: quantity, offer.currency: - money_amount} * * def _reject_polled_but_not_accepted_offers(self): # <<<<<<<<<<<<<< * cdef Offer offer * for offer in self._polled_offers.values(): */ - __pyx_tuple__44 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 634, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__44); - __Pyx_GIVEREF(__pyx_tuple__44); - __pyx_codeobj__45 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__44, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_reject_polled_but_not_accepted, 634, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__45)) __PYX_ERR(0, 634, __pyx_L1_error) + __pyx_tuple__35 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 727, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__35); + __Pyx_GIVEREF(__pyx_tuple__35); + __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_reject_polled_but_not_accepted, 727, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 727, __pyx_L1_error) - /* "trade.pyx":640 + /* "trade.pyx":733 * self._polled_offers = {} * * def _reject(self, offer): # <<<<<<<<<<<<<< * """ Rejects the offer offer * */ - __pyx_tuple__46 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(0, 640, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__46); - __Pyx_GIVEREF(__pyx_tuple__46); - __pyx_codeobj__47 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__46, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_reject_2, 640, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__47)) __PYX_ERR(0, 640, __pyx_L1_error) + __pyx_tuple__37 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 733, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__37); + __Pyx_GIVEREF(__pyx_tuple__37); + __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_reject_2, 733, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 733, __pyx_L1_error) - /* "trade.pyx":650 + /* "trade.pyx":743 * self._send(offer.sender, 'abce_receive_reject', offer.id) * * def reject(self, Offer offer): # <<<<<<<<<<<<<< * """ Rejects and offer, if the offer is subsequently accepted in the * same subround it is accepted'. Peaked offers can not be rejected. */ - __pyx_tuple__48 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(0, 650, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__48); - __Pyx_GIVEREF(__pyx_tuple__48); - __pyx_codeobj__49 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__48, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_reject, 650, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__49)) __PYX_ERR(0, 650, __pyx_L1_error) + __pyx_tuple__39 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 743, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__39); + __Pyx_GIVEREF(__pyx_tuple__39); + __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_reject, 743, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 743, __pyx_L1_error) - /* "trade.pyx":661 + /* "trade.pyx":754 * pass * * def _log_receive_accept_group(self, offer): # <<<<<<<<<<<<<< * if offer.sell: * self._trade_log[(offer.good, self.group, offer.receiver[0], offer.price)] += offer.quantity */ - __pyx_tuple__50 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(0, 661, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__50); - __Pyx_GIVEREF(__pyx_tuple__50); - __pyx_codeobj__51 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__50, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_log_receive_accept_group, 661, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__51)) __PYX_ERR(0, 661, __pyx_L1_error) + __pyx_tuple__41 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 754, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__41); + __Pyx_GIVEREF(__pyx_tuple__41); + __pyx_codeobj__42 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__41, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_log_receive_accept_group, 754, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__42)) __PYX_ERR(0, 754, __pyx_L1_error) - /* "trade.pyx":667 + /* "trade.pyx":760 * self._trade_log[(offer.good, offer.receiver[0], self.group, offer.price)] += offer.quantity * * def _log_receive_accept_agent(self, offer): # <<<<<<<<<<<<<< * if offer.sell: * self._trade_log[(offer.good, self.name_without_colon, '%s_%i' % ( */ - __pyx_tuple__52 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(0, 667, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__52); - __Pyx_GIVEREF(__pyx_tuple__52); - __pyx_codeobj__53 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__52, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_log_receive_accept_agent, 667, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__53)) __PYX_ERR(0, 667, __pyx_L1_error) + __pyx_tuple__43 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 760, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__43); + __Pyx_GIVEREF(__pyx_tuple__43); + __pyx_codeobj__44 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__43, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_log_receive_accept_agent, 760, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__44)) __PYX_ERR(0, 760, __pyx_L1_error) - /* "trade.pyx":675 + /* "trade.pyx":768 * offer.receiver[0], offer.receiver[1]), 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 */ - __pyx_tuple__54 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_offer_id_final_quantity, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__54)) __PYX_ERR(0, 675, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__54); - __Pyx_GIVEREF(__pyx_tuple__54); - __pyx_codeobj__55 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__54, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_receive_accept, 675, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__55)) __PYX_ERR(0, 675, __pyx_L1_error) + __pyx_tuple__45 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_offer_id_final_quantity, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 768, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__45); + __Pyx_GIVEREF(__pyx_tuple__45); + __pyx_codeobj__46 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__45, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_receive_accept, 768, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__46)) __PYX_ERR(0, 768, __pyx_L1_error) - /* "trade.pyx":693 + /* "trade.pyx":786 * return offer * * 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 */ - __pyx_tuple__56 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__56)) __PYX_ERR(0, 693, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__56); - __Pyx_GIVEREF(__pyx_tuple__56); - __pyx_codeobj__57 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__56, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_log_receive_accept_group, 693, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__57)) __PYX_ERR(0, 693, __pyx_L1_error) + __pyx_tuple__47 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 786, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__47); + __Pyx_GIVEREF(__pyx_tuple__47); + __pyx_codeobj__48 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_log_receive_accept_group, 786, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__48)) __PYX_ERR(0, 786, __pyx_L1_error) - /* "trade.pyx":699 + /* "trade.pyx":792 * self._trade_log[(offer.good, offer.receiver_group, self.group, offer.price)] += offer.final_quantity * * 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 */ - __pyx_tuple__58 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__58)) __PYX_ERR(0, 699, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__58); - __Pyx_GIVEREF(__pyx_tuple__58); - __pyx_codeobj__59 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__58, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_log_receive_accept_agent, 699, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__59)) __PYX_ERR(0, 699, __pyx_L1_error) + __pyx_tuple__49 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 792, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__49); + __Pyx_GIVEREF(__pyx_tuple__49); + __pyx_codeobj__50 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__49, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_log_receive_accept_agent, 792, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__50)) __PYX_ERR(0, 792, __pyx_L1_error) - /* "trade.pyx":705 + /* "trade.pyx":798 * 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): # <<<<<<<<<<<<<< * """ deletes a given offer * */ - __pyx_tuple__60 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_offer_id, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__60)) __PYX_ERR(0, 705, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__60); - __Pyx_GIVEREF(__pyx_tuple__60); - __pyx_codeobj__61 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__60, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_receive_reject, 705, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__61)) __PYX_ERR(0, 705, __pyx_L1_error) + __pyx_tuple__51 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_offer_id, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(0, 798, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__51); + __Pyx_GIVEREF(__pyx_tuple__51); + __pyx_codeobj__52 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__51, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_receive_reject, 798, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__52)) __PYX_ERR(0, 798, __pyx_L1_error) - /* "trade.pyx":722 + /* "trade.pyx":815 * del self.given_offers[offer_id] * * def _delete_given_offer(self, offer_id): # <<<<<<<<<<<<<< * cdef Offer offer = self.given_offers.pop(offer_id) * if offer.sell: */ - __pyx_tuple__62 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_offer_id, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__62)) __PYX_ERR(0, 722, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__62); - __Pyx_GIVEREF(__pyx_tuple__62); - __pyx_codeobj__63 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__62, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_delete_given_offer, 722, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__63)) __PYX_ERR(0, 722, __pyx_L1_error) + __pyx_tuple__53 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_offer_id, __pyx_n_s_offer); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(0, 815, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__53); + __Pyx_GIVEREF(__pyx_tuple__53); + __pyx_codeobj__54 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__53, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_delete_given_offer, 815, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__54)) __PYX_ERR(0, 815, __pyx_L1_error) - /* "trade.pyx":729 + /* "trade.pyx":822 * 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 * */ - __pyx_tuple__64 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_receiver, __pyx_n_s_good, __pyx_n_s_quantity, __pyx_n_s_epsilon, __pyx_n_s_available); if (unlikely(!__pyx_tuple__64)) __PYX_ERR(0, 729, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__64); - __Pyx_GIVEREF(__pyx_tuple__64); - __pyx_codeobj__65 = (PyObject*)__Pyx_PyCode_New(5, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__64, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_give, 729, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__65)) __PYX_ERR(0, 729, __pyx_L1_error) + __pyx_tuple__55 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_receiver, __pyx_n_s_good, __pyx_n_s_quantity, __pyx_n_s_epsilon, __pyx_n_s_available); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(0, 822, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__55); + __Pyx_GIVEREF(__pyx_tuple__55); + __pyx_codeobj__56 = (PyObject*)__Pyx_PyCode_New(5, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__55, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_give, 822, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__56)) __PYX_ERR(0, 822, __pyx_L1_error) - /* "trade.pyx":771 + /* "trade.pyx":864 * return {good: quantity} * * def take(self, receiver, good, double quantity, double epsilon=epsilon): # <<<<<<<<<<<<<< * """ take a good from another agent. The other agent has to accept. * using self.accept() */ - __pyx_tuple__66 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_receiver, __pyx_n_s_good, __pyx_n_s_quantity, __pyx_n_s_epsilon); if (unlikely(!__pyx_tuple__66)) __PYX_ERR(0, 771, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__66); - __Pyx_GIVEREF(__pyx_tuple__66); - __pyx_codeobj__67 = (PyObject*)__Pyx_PyCode_New(5, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__66, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_take, 771, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__67)) __PYX_ERR(0, 771, __pyx_L1_error) + __pyx_tuple__57 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_receiver, __pyx_n_s_good, __pyx_n_s_quantity, __pyx_n_s_epsilon); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(0, 864, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__57); + __Pyx_GIVEREF(__pyx_tuple__57); + __pyx_codeobj__58 = (PyObject*)__Pyx_PyCode_New(5, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__57, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_take, 864, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__58)) __PYX_ERR(0, 864, __pyx_L1_error) + + /* "trade.pyx":890 + * self.make_bid(receiver, good=good, quantity=quantity, price=0, epsilon=epsilon) + * + * def get_take(self, *args, **kwargs): # <<<<<<<<<<<<<< + * return self.get_bids(*args, **kwargs) + * + */ + __pyx_tuple__59 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_args, __pyx_n_s_kwargs); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(0, 890, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__59); + __Pyx_GIVEREF(__pyx_tuple__59); + __pyx_codeobj__60 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__59, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_trade_pyx, __pyx_n_s_get_take, 890, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__60)) __PYX_ERR(0, 890, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -14522,7 +13529,7 @@ static int __Pyx_modinit_function_import_code(void) { #ifndef CYTHON_SMALL_CODE #if defined(__clang__) #define CYTHON_SMALL_CODE -#elif defined(__GNUC__) +#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4))) #define CYTHON_SMALL_CODE __attribute__((optimize("Os"))) #else #define CYTHON_SMALL_CODE @@ -14822,329 +13829,302 @@ if (!__Pyx_RefNanny) { /* "trade.pyx":252 * self._trade_log = defaultdict(int) * - * 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} + * def get_bids_all(self, descending=True, sorted=True): # <<<<<<<<<<<<<< + * """ returns all bids in a dictionary, with goods as key. The in each + * goods-category the goods are ordered by price. The order can be reversed */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_7get_buy_offers_all, 0, __pyx_n_s_Trade_get_buy_offers_all, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 252, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_7get_bids_all, 0, __pyx_n_s_Trade_get_bids_all, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__13); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_get_buy_offers_all, __pyx_t_2) < 0) __PYX_ERR(0, 252, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "trade.pyx":256 - * return {good: self.get_offers(good, descending, sorted) for good in goods} - * - * 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_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_9get_sell_offers_all, 0, __pyx_n_s_Trade_get_sell_offers_all, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__15)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 256, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__16); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_get_sell_offers_all, __pyx_t_2) < 0) __PYX_ERR(0, 256, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_get_bids_all, __pyx_t_2) < 0) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":260 + /* "trade.pyx":289 * return {good: self.get_offers(good, descending, sorted) for good in goods} * * def get_offers_all(self, descending=False, sorted=True): # <<<<<<<<<<<<<< * """ returns all offers in a dictionary, with goods as key. The in each * goods-category the goods are ordered by price. The order can be reversed */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_11get_offers_all, 0, __pyx_n_s_Trade_get_offers_all, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__18)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 260, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_9get_offers_all, 0, __pyx_n_s_Trade_get_offers_all, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__15)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__19); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_get_offers_all, __pyx_t_2) < 0) __PYX_ERR(0, 260, __pyx_L1_error) + __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__16); + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_get_offers_all, __pyx_t_2) < 0) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":297 + /* "trade.pyx":326 * return {good: self.get_offers(good, descending, sorted) for good in goods} * - * 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]) - */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_13get_buy_offers, 0, __pyx_n_s_Trade_get_buy_offers, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__21)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 297, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__22); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_get_buy_offers, __pyx_t_2) < 0) __PYX_ERR(0, 297, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "trade.pyx":307 - * return ret + * def get_bids(self, good, sorted=True, descending=True, shuffled=True): # <<<<<<<<<<<<<< + * """ returns all bids of the 'good' ordered by price. * - * 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]) */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_15get_sell_offers, 0, __pyx_n_s_Trade_get_sell_offers, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__24)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_11get_bids, 0, __pyx_n_s_Trade_get_bids, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__18)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 326, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__25); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_get_sell_offers, __pyx_t_2) < 0) __PYX_ERR(0, 307, __pyx_L1_error) + __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__19); + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_get_bids, __pyx_t_2) < 0) __PYX_ERR(0, 326, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":317 + /* "trade.pyx":373 * return ret * * def get_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< * """ returns all offers of the 'good' ordered by price. * */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_17get_offers, 0, __pyx_n_s_Trade_get_offers, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__27)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 317, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_13get_offers, 0, __pyx_n_s_Trade_get_offers, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__21)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 373, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__28); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_get_offers, __pyx_t_2) < 0) __PYX_ERR(0, 317, __pyx_L1_error) + __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__22); + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_get_offers, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":363 - * return ret + /* "trade.pyx":421 * - * def peak_buy_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< - * ret = [] - * for offer in self._open_offers_buy[good].values(): - */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_19peak_buy_offers, 0, __pyx_n_s_Trade_peak_buy_offers, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__30)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 363, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__31); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_peak_buy_offers, __pyx_t_2) < 0) __PYX_ERR(0, 363, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "trade.pyx":373 - * return ret * - * def peak_sell_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< - * ret = [] - * for offer in self._open_offers_sell[good].values(): + * def peak_bids(self, good, sorted=True, descending=True, shuffled=True): # <<<<<<<<<<<<<< + * """ returns a peak on all bids for the 'good' ordered by price. + * Peaked bids can not be accepted or rejected and they do not */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_21peak_sell_offers, 0, __pyx_n_s_Trade_peak_sell_offers, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__33)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 373, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_15peak_bids, 0, __pyx_n_s_Trade_peak_bids, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__24)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__34); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_peak_sell_offers, __pyx_t_2) < 0) __PYX_ERR(0, 373, __pyx_L1_error) + __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__25); + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_peak_bids, __pyx_t_2) < 0) __PYX_ERR(0, 421, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":383 + /* "trade.pyx":464 * return ret * * def peak_offers(self, good, sorted=True, descending=False, shuffled=True): # <<<<<<<<<<<<<< * """ returns a peak on all offers of the 'good' ordered by price. * Peaked offers can not be accepted or rejected and they do not */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_23peak_offers, 0, __pyx_n_s_Trade_peak_offers, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__36)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 383, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_17peak_offers, 0, __pyx_n_s_Trade_peak_offers, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__27)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 464, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__37); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_peak_offers, __pyx_t_2) < 0) __PYX_ERR(0, 383, __pyx_L1_error) + __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__28); + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_peak_offers, __pyx_t_2) < 0) __PYX_ERR(0, 464, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":416 + /* "trade.pyx":509 * return ret * - * def sell(self, receiver, # <<<<<<<<<<<<<< - * good, double quantity, double price, str currency='money', double epsilon=epsilon): + * def make_offer(self, receiver, # <<<<<<<<<<<<<< + * good, double quantity, double price, str currency='money', double epsilon=epsilon): * """ commits to sell the quantity of good at price */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_25sell, 0, __pyx_n_s_Trade_sell, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__39)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 416, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_19make_offer, 0, __pyx_n_s_Trade_make_offer, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__30)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (!__Pyx_CyFunction_InitDefaults(__pyx_t_2, sizeof(__pyx_defaults), 0)) __PYX_ERR(0, 416, __pyx_L1_error) + if (!__Pyx_CyFunction_InitDefaults(__pyx_t_2, sizeof(__pyx_defaults), 0)) __PYX_ERR(0, 509, __pyx_L1_error) - /* "trade.pyx":417 + /* "trade.pyx":510 * - * def sell(self, receiver, - * good, double quantity, double price, str currency='money', double epsilon=epsilon): # <<<<<<<<<<<<<< + * def make_offer(self, receiver, + * good, double quantity, double price, str currency='money', double epsilon=epsilon): # <<<<<<<<<<<<<< * """ commits to sell the quantity of good at price * */ __Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_t_2)->__pyx_arg_epsilon = __pyx_v_5trade_epsilon; __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_2, __pyx_pf_5trade_4__defaults__); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_sell, __pyx_t_2) < 0) __PYX_ERR(0, 416, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_make_offer, __pyx_t_2) < 0) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":499 + /* "trade.pyx":592 * return offer * - * def buy(self, receiver, good, # <<<<<<<<<<<<<< + * def make_bid(self, receiver, good, # <<<<<<<<<<<<<< * double quantity, double price, str currency='money', double epsilon=epsilon): * """ commits to sell the quantity of good at price */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_27buy, 0, __pyx_n_s_Trade_buy, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__41)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 499, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_21make_bid, 0, __pyx_n_s_Trade_make_bid, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__32)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 592, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (!__Pyx_CyFunction_InitDefaults(__pyx_t_2, sizeof(__pyx_defaults1), 0)) __PYX_ERR(0, 499, __pyx_L1_error) + if (!__Pyx_CyFunction_InitDefaults(__pyx_t_2, sizeof(__pyx_defaults1), 0)) __PYX_ERR(0, 592, __pyx_L1_error) - /* "trade.pyx":500 + /* "trade.pyx":593 * - * def buy(self, receiver, good, + * def make_bid(self, receiver, good, * double quantity, double price, str currency='money', double epsilon=epsilon): # <<<<<<<<<<<<<< * """ commits to sell the quantity of good at price * */ __Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_t_2)->__pyx_arg_epsilon = __pyx_v_5trade_epsilon; __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_2, __pyx_pf_5trade_6__defaults__); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_buy, __pyx_t_2) < 0) __PYX_ERR(0, 499, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_make_bid, __pyx_t_2) < 0) __PYX_ERR(0, 592, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":563 + /* "trade.pyx":656 * 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 + * """ The offer or bid is accepted and cleared. If no quantity is + * given the offer/bid is fully accepted; If a quantity is given the offer/bid is */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_29accept, 0, __pyx_n_s_Trade_accept, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__43)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 563, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_23accept, 0, __pyx_n_s_Trade_accept, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__34)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (!__Pyx_CyFunction_InitDefaults(__pyx_t_2, sizeof(__pyx_defaults2), 0)) __PYX_ERR(0, 563, __pyx_L1_error) + if (!__Pyx_CyFunction_InitDefaults(__pyx_t_2, sizeof(__pyx_defaults2), 0)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_CyFunction_Defaults(__pyx_defaults2, __pyx_t_2)->__pyx_arg_epsilon = __pyx_v_5trade_epsilon; __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_2, __pyx_pf_5trade_8__defaults__); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_accept, __pyx_t_2) < 0) __PYX_ERR(0, 563, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_accept, __pyx_t_2) < 0) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":634 + /* "trade.pyx":727 * return {offer.good: quantity, offer.currency: - money_amount} * * def _reject_polled_but_not_accepted_offers(self): # <<<<<<<<<<<<<< * cdef Offer offer * for offer in self._polled_offers.values(): */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_31_reject_polled_but_not_accepted_offers, 0, __pyx_n_s_Trade__reject_polled_but_not_acc, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__45)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 634, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_25_reject_polled_but_not_accepted_offers, 0, __pyx_n_s_Trade__reject_polled_but_not_acc, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__36)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 727, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_reject_polled_but_not_accepted, __pyx_t_2) < 0) __PYX_ERR(0, 634, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_reject_polled_but_not_accepted, __pyx_t_2) < 0) __PYX_ERR(0, 727, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":640 + /* "trade.pyx":733 * self._polled_offers = {} * * def _reject(self, offer): # <<<<<<<<<<<<<< * """ Rejects the offer offer * */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_33_reject, 0, __pyx_n_s_Trade__reject, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__47)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 640, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_27_reject, 0, __pyx_n_s_Trade__reject, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 733, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_reject_2, __pyx_t_2) < 0) __PYX_ERR(0, 640, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_reject_2, __pyx_t_2) < 0) __PYX_ERR(0, 733, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":650 + /* "trade.pyx":743 * self._send(offer.sender, 'abce_receive_reject', offer.id) * * def reject(self, Offer offer): # <<<<<<<<<<<<<< * """ Rejects and offer, if the offer is subsequently accepted in the * same subround it is accepted'. Peaked offers can not be rejected. */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_35reject, 0, __pyx_n_s_Trade_reject, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__49)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 650, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_29reject, 0, __pyx_n_s_Trade_reject, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__40)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 743, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_reject, __pyx_t_2) < 0) __PYX_ERR(0, 650, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_reject, __pyx_t_2) < 0) __PYX_ERR(0, 743, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":661 + /* "trade.pyx":754 * pass * * def _log_receive_accept_group(self, offer): # <<<<<<<<<<<<<< * if offer.sell: * self._trade_log[(offer.good, self.group, offer.receiver[0], offer.price)] += offer.quantity */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_37_log_receive_accept_group, 0, __pyx_n_s_Trade__log_receive_accept_group, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__51)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 661, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_31_log_receive_accept_group, 0, __pyx_n_s_Trade__log_receive_accept_group, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__42)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 754, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_log_receive_accept_group, __pyx_t_2) < 0) __PYX_ERR(0, 661, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_log_receive_accept_group, __pyx_t_2) < 0) __PYX_ERR(0, 754, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":667 + /* "trade.pyx":760 * self._trade_log[(offer.good, offer.receiver[0], self.group, offer.price)] += offer.quantity * * def _log_receive_accept_agent(self, offer): # <<<<<<<<<<<<<< * if offer.sell: * self._trade_log[(offer.good, self.name_without_colon, '%s_%i' % ( */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_39_log_receive_accept_agent, 0, __pyx_n_s_Trade__log_receive_accept_agent, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__53)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 667, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_33_log_receive_accept_agent, 0, __pyx_n_s_Trade__log_receive_accept_agent, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__44)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 760, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_log_receive_accept_agent, __pyx_t_2) < 0) __PYX_ERR(0, 667, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_log_receive_accept_agent, __pyx_t_2) < 0) __PYX_ERR(0, 760, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":675 + /* "trade.pyx":768 * offer.receiver[0], offer.receiver[1]), 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 */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_41_receive_accept, 0, __pyx_n_s_Trade__receive_accept, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__55)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 675, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_35_receive_accept, 0, __pyx_n_s_Trade__receive_accept, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__46)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 768, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_receive_accept, __pyx_t_2) < 0) __PYX_ERR(0, 675, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_receive_accept, __pyx_t_2) < 0) __PYX_ERR(0, 768, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":693 + /* "trade.pyx":786 * return offer * * 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 */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_43_log_receive_accept_group, 0, __pyx_n_s_Trade__log_receive_accept_group, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__57)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 693, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_37_log_receive_accept_group, 0, __pyx_n_s_Trade__log_receive_accept_group, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__48)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 786, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_log_receive_accept_group, __pyx_t_2) < 0) __PYX_ERR(0, 693, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_log_receive_accept_group, __pyx_t_2) < 0) __PYX_ERR(0, 786, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":699 + /* "trade.pyx":792 * self._trade_log[(offer.good, offer.receiver_group, self.group, offer.price)] += offer.final_quantity * * 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 */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_45_log_receive_accept_agent, 0, __pyx_n_s_Trade__log_receive_accept_agent, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__59)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 699, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_39_log_receive_accept_agent, 0, __pyx_n_s_Trade__log_receive_accept_agent, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__50)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 792, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_log_receive_accept_agent, __pyx_t_2) < 0) __PYX_ERR(0, 699, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_log_receive_accept_agent, __pyx_t_2) < 0) __PYX_ERR(0, 792, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":705 + /* "trade.pyx":798 * 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): # <<<<<<<<<<<<<< * """ deletes a given offer * */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_47_receive_reject, 0, __pyx_n_s_Trade__receive_reject, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__61)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 705, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_41_receive_reject, 0, __pyx_n_s_Trade__receive_reject, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__52)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 798, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_receive_reject, __pyx_t_2) < 0) __PYX_ERR(0, 705, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_receive_reject, __pyx_t_2) < 0) __PYX_ERR(0, 798, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":722 + /* "trade.pyx":815 * del self.given_offers[offer_id] * * def _delete_given_offer(self, offer_id): # <<<<<<<<<<<<<< * cdef Offer offer = self.given_offers.pop(offer_id) * if offer.sell: */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_49_delete_given_offer, 0, __pyx_n_s_Trade__delete_given_offer, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__63)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 722, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_43_delete_given_offer, 0, __pyx_n_s_Trade__delete_given_offer, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__54)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 815, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_delete_given_offer, __pyx_t_2) < 0) __PYX_ERR(0, 722, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_delete_given_offer, __pyx_t_2) < 0) __PYX_ERR(0, 815, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":729 + /* "trade.pyx":822 * 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 * */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_51give, 0, __pyx_n_s_Trade_give, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__65)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 729, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_45give, 0, __pyx_n_s_Trade_give, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__56)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 822, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (!__Pyx_CyFunction_InitDefaults(__pyx_t_2, sizeof(__pyx_defaults3), 0)) __PYX_ERR(0, 729, __pyx_L1_error) + if (!__Pyx_CyFunction_InitDefaults(__pyx_t_2, sizeof(__pyx_defaults3), 0)) __PYX_ERR(0, 822, __pyx_L1_error) __Pyx_CyFunction_Defaults(__pyx_defaults3, __pyx_t_2)->__pyx_arg_epsilon = __pyx_v_5trade_epsilon; __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_2, __pyx_pf_5trade_10__defaults__); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_give, __pyx_t_2) < 0) __PYX_ERR(0, 729, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_give, __pyx_t_2) < 0) __PYX_ERR(0, 822, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "trade.pyx":771 + /* "trade.pyx":864 * return {good: quantity} * * def take(self, receiver, good, double quantity, double epsilon=epsilon): # <<<<<<<<<<<<<< * """ take a good from another agent. The other agent has to accept. * using self.accept() */ - __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_53take, 0, __pyx_n_s_Trade_take, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__67)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 771, __pyx_L1_error) + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_47take, 0, __pyx_n_s_Trade_take, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__58)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 864, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - if (!__Pyx_CyFunction_InitDefaults(__pyx_t_2, sizeof(__pyx_defaults4), 0)) __PYX_ERR(0, 771, __pyx_L1_error) + if (!__Pyx_CyFunction_InitDefaults(__pyx_t_2, sizeof(__pyx_defaults4), 0)) __PYX_ERR(0, 864, __pyx_L1_error) __Pyx_CyFunction_Defaults(__pyx_defaults4, __pyx_t_2)->__pyx_arg_epsilon = __pyx_v_5trade_epsilon; __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_2, __pyx_pf_5trade_12__defaults__); - if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_take, __pyx_t_2) < 0) __PYX_ERR(0, 771, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_take, __pyx_t_2) < 0) __PYX_ERR(0, 864, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "trade.pyx":890 + * self.make_bid(receiver, good=good, quantity=quantity, price=0, epsilon=epsilon) + * + * def get_take(self, *args, **kwargs): # <<<<<<<<<<<<<< + * return self.get_bids(*args, **kwargs) + * + */ + __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5trade_5Trade_49get_take, 0, __pyx_n_s_Trade_get_take, NULL, __pyx_n_s_trade, __pyx_d, ((PyObject *)__pyx_codeobj__60)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 890, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_get_take, __pyx_t_2) < 0) __PYX_ERR(0, 890, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "trade.pyx":157 @@ -17182,6 +16162,9 @@ static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_li #if CYTHON_COMPILING_IN_CPYTHON PyObject **cython_runtime_dict; #endif + if (unlikely(!__pyx_cython_runtime)) { + return c_line; + } __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); #if CYTHON_COMPILING_IN_CPYTHON cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); @@ -18167,6 +17150,9 @@ static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_DECREF(x); return ival; } +static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { + return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); +} static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); } diff --git a/abce/trade.py b/abce/trade.py index ed1941e3..0aadb97a 100644 --- a/abce/trade.py +++ b/abce/trade.py @@ -103,7 +103,7 @@ class Offer(object): a unique identifier """ def __init__(self, sender, receiver, good, quantity, price, currency, - sell, id, made): + sell, status, final_quantity, id, made, status_round): self.sender = sender self.receiver = receiver self.good = good @@ -111,11 +111,11 @@ def __init__(self, sender, receiver, good, quantity, price, currency, self.quantity = quantity self.price = price self.sell = sell - self.status = 'new' - self.final_quantity = None + self.status = status + self.final_quantity = final_quantity self.id = id self.made = made - self.status_round = None + self.status_round = status_round def __repr__(self): return ("""<{sender: %s, receiver: %s, good: %s, quantity: %f, price: %f, currency: %f, @@ -219,27 +219,54 @@ def _advance_round(self, time): self.database_connection.put(["trade_log", self._trade_log, self.time]) self._trade_log = defaultdict(int) - def get_buy_offers_all(self, descending=False, sorted=True): - """ """ - goods = list(self._open_offers_buy.keys()) - return {good: self.get_buy_offers(good, descending, sorted) for good in goods} + def get_bids_all(self, descending=True, sorted=True): + """ returns all bids in a dictionary, with goods as key. The in each + goods-category the goods are ordered by price. The order can be reversed + by setting descending=False - def get_sell_offers_all(self, descending=False, sorted=True): - """ """ - goods = list(self._open_offers_sell.keys()) - return {good: self.get_sell_offers(good, descending, sorted) for good in goods} + *Bids that are not accepted in the same subround are + automatically rejected.* However you can also manually reject. + + Args: + + descending(=True): + False for descending True for ascending by price + + sorted(=True): + Whether offers are sorted by price. Faster if False. + + Returns: + + a dictionary with good types as keys and list of :class:`abce.trade.Offer` + as values + + Example:: + + oo = get_bids_all() + for good_category in oo: + print('The most expensive offer for good in category' + good_category + + ' is ' + good_category[0]) + for bid in oo[good_category]: + if bid.price < 0.5: + self.accept(bid) + + for bid in oo.beer: + print(bid.price, bid.sender_group, bid.sender_id) + """ + goods = list(self._open_offers_buy.keys()) + return {good: self.get_offers(good, descending, sorted) for good in goods} def get_offers_all(self, descending=False, sorted=True): """ returns all offers in a dictionary, with goods as key. The in each goods-category the goods are ordered by price. The order can be reversed by setting descending=True - *Offers that are not accepted in the same subround (def block) are + *Offers that are not accepted in the same subround are automatically rejected.* However you can also manually reject. Args: - descending(optional): + descending(=False): is a bool. False for descending True for ascending by price sorted(default=True): @@ -263,11 +290,47 @@ def get_offers_all(self, descending=False, sorted=True): for offer in oo.beer: print(offer.price, offer.sender) """ - goods = list(self._open_offers_sell.keys() + self._open_offers_buy.keys()) + goods = list(self._open_offers_sell.keys()) return {good: self.get_offers(good, descending, sorted) for good in goods} - def get_buy_offers(self, good, sorted=True, descending=False, shuffled=True): - """ """ + def get_bids(self, good, sorted=True, descending=True, shuffled=True): + """ returns all bids of the 'good' ordered by price. + + *Bids that are not accepted in the same subround are + automatically rejected.* However you can also manually reject. + + peek_bids can be used to look at the bids without them being + rejected automatically + + Args: + good: + the good which should be retrieved + + sorted(=True): + Whether bids are sorted by price. Faster if False. + + descending(=True): + False for descending True for ascending by price + + shuffled(=True): + whether the order of messages is randomized or correlated with + the ID of the agent. Setting this to False speeds up the + simulation considerably, but introduces a bias. + + Returns: + A list of :class:`abce.trade.Offer` ordered by price. + + Example:: + + bids = get_bids('books') + for bid in bids: + if offer.price < 50: + self.accept(bid) + elif bid.price < 100: + self.accept(bid, 1) + else: + self.reject(bid) # optional + """ ret = list(self._open_offers_buy[good].values()) self._polled_offers.update(self._open_offers_buy[good]) del self._open_offers_buy[good] @@ -277,21 +340,10 @@ def get_buy_offers(self, good, sorted=True, descending=False, shuffled=True): ret.sort(key=lambda objects: objects.price, reverse=descending) return ret - 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: - random.shuffle(ret) - if sorted: - ret.sort(key=lambda objects: objects.price, reverse=descending) - return ret - def get_offers(self, good, sorted=True, descending=False, shuffled=True): """ returns all offers of the 'good' ordered by price. - *Offers that are not accepted in the same subround (def block) are + *Offers that are not accepted in the same subround are automatically rejected.* However you can also manually reject. peek_offers can be used to look at the offers without them being @@ -301,13 +353,13 @@ def get_offers(self, good, sorted=True, descending=False, shuffled=True): good: the good which should be retrieved - sorted(bool, default=True): + sorted(=True): Whether offers are sorted by price. Faster if False. - descending(bool, default=False): + descending(=False): False for descending True for ascending by price - shuffled(bool, default=True): + shuffled(=True): whether the order of messages is randomized or correlated with the ID of the agent. Setting this to False speeds up the simulation considerably, but introduces a bias. @@ -326,29 +378,52 @@ def get_offers(self, good, sorted=True, descending=False, shuffled=True): else: 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)) + 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) if sorted: ret.sort(key=lambda objects: objects.price, reverse=descending) return ret - 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: - random.shuffle(ret) - if sorted: - ret.sort(key=lambda objects: objects.price, reverse=descending) - return ret - def peak_sell_offers(self, good, sorted=True, descending=False, shuffled=True): - """ """ + def peak_bids(self, good, sorted=True, descending=True, shuffled=True): + """ returns a peak on all bids for the 'good' ordered by price. + Peaked bids can not be accepted or rejected and they do not + expire. + + Args: + good: + the good which should be retrieved + descending(bool, default=False): + False for descending True for ascending by price + + sorted(=True): + whether the bids are sorted, switch off for speed + + descending(=True): + sort order + + shuffled(=True): + randomizes equal prized bids, switch off for speed + + Returns: + A list of bids ordered by price + + Example:: + + bids = get_bids('books') + for bid in bids: + if bid.price < 50: + self.accept(bid) + elif bid.price < 100: + self.accept(bid, 1) + else: + self.reject(bid) # optional + """ ret = [] - for offer in self._open_offers_sell[good].values(): + for offer in self._open_offers_buy[good].values(): ret.append(offer) if shuffled: random.shuffle(ret) @@ -367,6 +442,17 @@ def peak_offers(self, good, sorted=True, descending=False, shuffled=True): descending(bool, default=False): False for descending True for ascending by price + + sorted(=True): + whether the bids are sorted, switch off for speed + + descending(=False): + sort order + + shuffled(=True): + randomizes equal prized bids, switch off for speed + + Returns: A list of offers ordered by price @@ -381,18 +467,22 @@ def peak_offers(self, good, sorted=True, descending=False, shuffled=True): else: 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)) + ret = [] + for offer in self._open_offers_sell[good].values(): + ret.append(offer) if shuffled: random.shuffle(ret) if sorted: ret.sort(key=lambda objects: objects.price, reverse=descending) return ret - def sell(self, receiver, - good, quantity, price, currency='money', epsilon=epsilon): - """ Sends a offer to sell a particular good to somebody. The amount promised - is reserved. (self.free(good), shows the not yet reserved goods) + def make_offer(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) Args: receiver: @@ -402,7 +492,7 @@ def sell(self, receiver, name of the good quantity: - maximum units disposed to buy at this price + maximum units disposeable to buy at this price price: price per unit @@ -422,7 +512,7 @@ def sell(self, receiver, Example:: def subround_1(self): - self.offer = self.sell('household', 1, 'cookies', quantity=5, price=0.1) + self.offer = self.make_offer('household', 1, 'cookies', quantity=5, price=0.1) def subround_2(self): offer = self.info(self.offer) @@ -442,7 +532,6 @@ def subround_2(self): quantity = 0 self._inventory.reserve(good, quantity) - offer_id = self._offer_counter() offer = Offer(self.name, receiver, @@ -451,16 +540,22 @@ def subround_2(self): price, currency, True, + 'new', + -2, offer_id, - self.time) + self.time, + -2) self.given_offers[offer_id] = offer self._send(receiver, 'abce_propose_sell', offer) return offer - def buy(self, receiver, good, - quantity, price, currency='money', epsilon=epsilon): - """ Sends a offer to buy a particular good to somebody. The money promised - is reserved. (self.free(currency), shows the not yet reserved goods) + def make_bid(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) Args: receiver: @@ -471,7 +566,7 @@ def buy(self, receiver, good, name of the good quantity: - maximum units disposed to buy at this price + maximum units available to buy at this price price: price per unit @@ -506,15 +601,18 @@ def buy(self, receiver, good, price, currency, False, + 'new', + -1, offer_id, - self.time) + self.time, + -1) self._send(receiver, 'abce_propose_buy', offer) self.given_offers[offer_id] = offer return offer def accept(self, offer, quantity=-999, 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 + """ The offer or bid is accepted and cleared. If no quantity is + given the offer/bid is fully accepted; If a quantity is given the offer/bid is partial accepted. Args: @@ -708,8 +806,11 @@ def take(self, receiver, good, quantity, epsilon=epsilon): Args: - receiver: - the receiving agent + receiver_group: + group of the receiving agent + + receiver_id: + number of the receiving agent good: the good to be taken @@ -722,8 +823,10 @@ def take(self, receiver, good, quantity, epsilon=epsilon): a fraction of number to high or low. You can increase the floating point tolerance. See troubleshooting -- floating point problems """ - self.buy(receiver, good=good, quantity=quantity, price=0, epsilon=epsilon) + self.make_bid(receiver, good=good, quantity=quantity, price=0, epsilon=epsilon) + def get_take(self, *args, **kwargs): + return self.get_bids(*args, **kwargs) def compare_with_ties(x, y): if x < y: diff --git a/abce/trade.pyx b/abce/trade.pyx index 861c0bec..6358a2fd 100644 --- a/abce/trade.pyx +++ b/abce/trade.pyx @@ -161,7 +161,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` @@ -171,7 +171,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` @@ -249,12 +249,41 @@ class Trade: self.database_connection.put(["trade_log", self._trade_log, self.time]) self._trade_log = defaultdict(int) - 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} + def get_bids_all(self, descending=True, sorted=True): + """ returns all bids in a dictionary, with goods as key. The in each + goods-category the goods are ordered by price. The order can be reversed + by setting descending=False - def get_sell_offers_all(self, descending=False, sorted=True): - goods = list(self._open_offers_sell.keys()) + *Bids that are not accepted in the same subround are + automatically rejected.* However you can also manually reject. + + Args: + + descending(=True): + False for descending True for ascending by price + + sorted(=True): + Whether offers are sorted by price. Faster if False. + + Returns: + + a dictionary with good types as keys and list of :class:`abce.trade.Offer` + as values + + Example:: + + oo = get_bids_all() + for good_category in oo: + print('The most expensive offer for good in category' + good_category + + ' is ' + good_category[0]) + for bid in oo[good_category]: + if bid.price < 0.5: + self.accept(bid) + + for bid in oo.beer: + print(bid.price, bid.sender_group, bid.sender_id) + """ + goods = list(self._open_offers_buy.keys()) return {good: self.get_offers(good, descending, sorted) for good in goods} def get_offers_all(self, descending=False, sorted=True): @@ -262,12 +291,12 @@ class Trade: goods-category the goods are ordered by price. The order can be reversed by setting descending=True - *Offers that are not accepted in the same subround (def block) are + *Offers that are not accepted in the same subround are automatically rejected.* However you can also manually reject. Args: - descending(optional): + descending(=False): is a bool. False for descending True for ascending by price sorted(default=True): @@ -291,10 +320,47 @@ class Trade: for offer in oo.beer: print(offer.price, offer.sender_group, offer.sender_id) """ - goods = list(self._open_offers_sell.keys()) + list(self._open_offers_buy.keys()) + goods = list(self._open_offers_sell.keys()) return {good: self.get_offers(good, descending, sorted) for good in goods} - def get_buy_offers(self, good, sorted=True, descending=False, shuffled=True): + def get_bids(self, good, sorted=True, descending=True, shuffled=True): + """ returns all bids of the 'good' ordered by price. + + *Bids that are not accepted in the same subround are + automatically rejected.* However you can also manually reject. + + peek_bids can be used to look at the bids without them being + rejected automatically + + Args: + good: + the good which should be retrieved + + sorted(=True): + Whether bids are sorted by price. Faster if False. + + descending(=True): + False for descending True for ascending by price + + shuffled(=True): + whether the order of messages is randomized or correlated with + the ID of the agent. Setting this to False speeds up the + simulation considerably, but introduces a bias. + + Returns: + A list of :class:`abce.trade.Offer` ordered by price. + + Example:: + + bids = get_bids('books') + for bid in bids: + if offer.price < 50: + self.accept(bid) + elif bid.price < 100: + self.accept(bid, 1) + else: + self.reject(bid) # optional + """ ret = list(self._open_offers_buy[good].values()) self._polled_offers.update(self._open_offers_buy[good]) del self._open_offers_buy[good] @@ -304,20 +370,10 @@ class Trade: ret.sort(key=lambda objects: objects.price, reverse=descending) return ret - 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: - random.shuffle(ret) - if sorted: - ret.sort(key=lambda objects: objects.price, reverse=descending) - return ret - def get_offers(self, good, sorted=True, descending=False, shuffled=True): """ returns all offers of the 'good' ordered by price. - *Offers that are not accepted in the same subround (def block) are + *Offers that are not accepted in the same subround are automatically rejected.* However you can also manually reject. peek_offers can be used to look at the offers without them being @@ -327,13 +383,13 @@ class Trade: good: the good which should be retrieved - sorted(bool, default=True): + sorted(=True): Whether offers are sorted by price. Faster if False. - descending(bool, default=False): + descending(=False): False for descending True for ascending by price - shuffled(bool, default=True): + shuffled(=True): whether the order of messages is randomized or correlated with the ID of the agent. Setting this to False speeds up the simulation considerably, but introduces a bias. @@ -352,27 +408,52 @@ class Trade: else: 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)) + 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) if sorted: ret.sort(key=lambda objects: objects.price, reverse=descending) return ret - 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: - random.shuffle(ret) - if sorted: - ret.sort(key=lambda objects: objects.price, reverse=descending) - return ret - def peak_sell_offers(self, good, sorted=True, descending=False, shuffled=True): + def peak_bids(self, good, sorted=True, descending=True, shuffled=True): + """ returns a peak on all bids for the 'good' ordered by price. + Peaked bids can not be accepted or rejected and they do not + expire. + + Args: + good: + the good which should be retrieved + descending(bool, default=False): + False for descending True for ascending by price + + sorted(=True): + whether the bids are sorted, switch off for speed + + descending(=True): + sort order + + shuffled(=True): + randomizes equal prized bids, switch off for speed + + Returns: + A list of bids ordered by price + + Example:: + + bids = get_bids('books') + for bid in bids: + if bid.price < 50: + self.accept(bid) + elif bid.price < 100: + self.accept(bid, 1) + else: + self.reject(bid) # optional + """ ret = [] - for offer in self._open_offers_sell[good].values(): + for offer in self._open_offers_buy[good].values(): ret.append(offer) if shuffled: random.shuffle(ret) @@ -391,6 +472,17 @@ class Trade: descending(bool, default=False): False for descending True for ascending by price + + sorted(=True): + whether the bids are sorted, switch off for speed + + descending(=False): + sort order + + shuffled(=True): + randomizes equal prized bids, switch off for speed + + Returns: A list of offers ordered by price @@ -405,16 +497,17 @@ class Trade: else: 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)) + ret = [] + for offer in self._open_offers_sell[good].values(): + ret.append(offer) if shuffled: random.shuffle(ret) if sorted: ret.sort(key=lambda objects: objects.price, reverse=descending) return ret - def sell(self, receiver, - good, double quantity, double price, str currency='money', double epsilon=epsilon): + def make_offer(self, receiver, + good, double quantity, double price, str 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 @@ -423,11 +516,8 @@ class Trade: accordingly) Args: - receiver_group: - group of the receiving agent - - receiver_id: - number of the receiving agent + receiver: + the receiving agent 'good': name of the good @@ -453,7 +543,7 @@ class Trade: Example:: def subround_1(self): - self.offer = self.sell('household', 1, 'cookies', quantity=5, price=0.1) + self.offer = self.make_offer('household', 1, 'cookies', quantity=5, price=0.1) def subround_2(self): offer = self.info(self.offer) @@ -496,7 +586,7 @@ class Trade: self._send(receiver, 'abce_propose_sell', offer) return offer - def buy(self, receiver, good, + def make_bid(self, receiver, good, double quantity, double price, str currency='money', double epsilon=epsilon): """ commits to sell the quantity of good at price @@ -514,7 +604,7 @@ class Trade: name of the good quantity: - maximum units disposed to buy at this price + maximum units available to buy at this price price: price per unit @@ -561,8 +651,8 @@ class Trade: 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 + """ The offer or bid is accepted and cleared. If no quantity is + given the offer/bid is fully accepted; If a quantity is given the offer/bid is partial accepted. Args: @@ -792,8 +882,10 @@ class Trade: a fraction of number to high or low. You can increase the floating point tolerance. See troubleshooting -- floating point problems """ - self.buy(receiver, good=good, quantity=quantity, price=0, epsilon=epsilon) + self.make_bid(receiver, good=good, quantity=quantity, price=0, epsilon=epsilon) + def get_take(self, *args, **kwargs): + return self.get_bids(*args, **kwargs) # 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): diff --git a/setup.py b/setup.py index d0dfac24..46a6954c 100644 --- a/setup.py +++ b/setup.py @@ -61,7 +61,7 @@ def build_extension(self, ext): 'tornado == 4.3'] -version = '0.9.5b0' +version = '0.9.6b0' setup(name='abce', diff --git a/unittest/buy.py b/unittest/buy.py index d8dde3b7..4427b544 100644 --- a/unittest/buy.py +++ b/unittest/buy.py @@ -20,7 +20,7 @@ def one(self): 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), + self.offer = self.make_bid(('buy', self.id + 1), 'cookies', quantity, self.price) assert self.not_reserved('money') == self.money - \ quantity * self.price @@ -32,7 +32,7 @@ def two(self): if self.id % 2 == 1: self.create('cookies', random.uniform(0, 10000)) cookies = self['cookies'] - oo = self.get_offers('cookies') + oo = self.get_bids('cookies') assert oo for offer in oo: if random.randint(0, 10) == 0: diff --git a/unittest/sell.py b/unittest/sell.py index 984608aa..ab9a07ac 100644 --- a/unittest/sell.py +++ b/unittest/sell.py @@ -18,7 +18,7 @@ def one(self): 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), + self.offer = self.make_offer(receiver=('sell', self.id + 1), good='cookies', quantity=quantity, price=self.price) assert self.not_reserved('cookies') == self.cookies - quantity diff --git a/unittest/start.py b/unittest/start.py index fa07135b..0a887ef5 100644 --- a/unittest/start.py +++ b/unittest/start.py @@ -12,7 +12,7 @@ import start_individual_access import start_service import start_transform - +import start_take def run_test(name, test): print(name + " test, 1 core") @@ -41,3 +41,4 @@ def run_test(name, test): run_test("start_individual_access", start_individual_access) run_test("Test service", start_service) run_test("Test Transform method", start_transform) + run_test("Test taking", start_take) diff --git a/unittest/start_take.py b/unittest/start_take.py new file mode 100644 index 00000000..cee18391 --- /dev/null +++ b/unittest/start_take.py @@ -0,0 +1,37 @@ +import abce + + +class Taker(abce.Agent): + def init(self): + pass + + def do_take(self): + self.take(('victim', 0), 'money', self.time) + + +class Victim(abce.Agent): + def init(self): + self.create('money', 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2) + self._money = self['money'] + + def accept_taking(self): + for theft in self.get_take('money'): + self.accept(theft) + self._money -= self.time + assert self['money'] == self._money + + +def main(rounds, processes): + sim = abce.Simulation(processes=processes) + takers = sim.build_agents(Taker, 'taker', number=1) + victims = sim.build_agents(Victim, 'victim', number=1) + + for r in range(10): + sim.time = r + takers.do_take() + victims.accept_taking() + sim.finalize() + + +if __name__ == '__main__': + main(10, 1)