pymarket.mechanisms.huang_auction module¶
-
class
pymarket.mechanisms.huang_auction.
HuangAuction
(bids, *args, **kwargs)[source]¶ Bases:
pymarket.mechanisms.mechanism.Mechanism
Iinterface for the HuangAuction
Parameters: - bids (pd.DataFrame) – Collection of bids to use in the market
- merge (bool) – Wheather to merge players with the same price. Always True
-
pymarket.mechanisms.huang_auction.
huang_auction
(bids)[source]¶ Implements the auction described in [1]
Parameters: bids (pd.DataFrame) – Collection of all the bids to take into account by the mechanism Returns: - trans (TransactionManager) – Collection of all the trasactions cleared by the mechanism
- extra (dict) – Extra information provided by the mecanism. Keys: * price_sell: price at which sellers traded * price_buy: price at which the buyers traded * quantity_traded: the total quantity traded
Notes
[1] Huang, Pu, Alan Scheller–Wolf, and Katia Sycara. “Design of a multi–unit double auction e–market.” Computational Intelligence 18.4 (2002): 596-617.
Examples
No trade because price setters don’t trade:
>>> bm = pm.BidManager() >>> bm.add_bid(1, 3, 0) 0 >>> bm.add_bid(2, 1, 1) 1 >>> bm.add_bid(2, 2, 2, False) 2 >>> trans, extra = huang_auction(bm.get_df()) >>> trans.get_df() Empty DataFrame Columns: [bid, quantity, price, source, active] Index: [] >>> extra OrderedDict([('price_sell', 2.0), ('price_buy', 3.0), ('quantity_traded', 0)])
Adding small bids at the beginning, those can trade because they don’t define de market price:
>>> bm.add_bid(0.3, 1, 3, False) 3 >>> bm.add_bid(0.2, 3.3, 4) 4 >>> trans, extra = huang_auction(bm.get_df()) >>> trans.get_df() bid quantity price source active 0 3 0.2 2.0 -1 False 1 4 0.2 3.0 -1 False >>> extra OrderedDict([('price_sell', 2.0), ('price_buy', 3.0), ('quantity_traded', 0.2)])
-
pymarket.mechanisms.huang_auction.
update_quantity
(quantity, gap)[source]¶ Implements the footnote in page 8 of [1], where the long side updates their trading quantities to match the short side.
Parameters: - quantity (np.ndarray) – List of the quantities to be traded by each player.
- gap (float) – Difference between the short and long side
Returns: quantity – Updated list of quantities to be traded by each player
Return type: np.ndarray
Notes
[1] Huang, Pu, Alan Scheller–Wolf, and Katia Sycara. “Design of a multi–unit double auction e–market.” Computational Intelligence 18.4 (2002): 596-617.
Examples
All keep trading, with less quantity
>>> l, g = np.array([1, 2, 3]), 0.6 >>> update_quantity(l, g) array([0.8, 1.8, 2.8])
The gap is to big for small trader:
>>> l,g = np.array([1, 0.5, 2]), 1.8 >>> update_quantity(l, g) array([0.35, 0. , 1.35])