pymarket.statistics.maximum_traded_volume module¶

pymarket.statistics.maximum_traded_volume.
maximum_traded_volume
(bids, *args, reservation_prices={})[source]¶ Parameters:  bids (pd.DataFrame) – Collections of bids
 reservation_prices (dict of floats or None, (Default value = None)) – A maping from user ids to reservation prices. If no reservation price for a user is given, his bid will be assumed to be his true value.
Returns:  status (str) – Status of the optimization problem. Desired output is ‘Optimal’
 objective (float) – Maximum tradable volume that can be obtained
 variables (dict) – A set of values achieving the objective. Maps a pair of bids to the quantity traded by them.
Examples
>>> bm = pm.BidManager() >>> bm.add_bid(1, 3, 0) 0 >>> bm.add_bid(1, 2, 1) 1 >>> bm.add_bid(1.5, 1, 2, False) 2 >>> s, o, v = maximum_traded_volume(bm.get_df()) >>> s 'Optimal' >>> o 1.5 >>> v OrderedDict([((0, 2), 0.5), ((1, 2), 1.0)])

pymarket.statistics.maximum_traded_volume.
percentage_traded
(bids, transactions, reservation_prices={}, **kwargs)[source]¶ Calculates from the transaction dataframe the percentage of the total maximum possible traded quantity.
Parameters:  (pandas dataframe) (transactions) – Table with all the submited bids
 (pandas dataframe) – Table with all the transactions that ocurred in the market
 (dict, optional) (reservation_prices) – Reservation prices of the different participants. If None, the bids will be assumed to be the truthfull values.
Returns: ratio – The ratio of the maximum social welfare achieved by the collection of transactions.
Return type: Examples
Only bid 0 and 2 trade 1 unit. That represents the 66% of all that could have been traded.
>>> tm = pm.TransactionManager() >>> bm = pm.BidManager() >>> bm.add_bid(1, 3, 0) 0 >>> bm.add_bid(1, 2, 1) 1 >>> bm.add_bid(1.5, 1, 2, False) 2 >>> tm.add_transaction(0, 1, 2, 2, False) 0 >>> tm.add_transaction(2, 1, 2, 0, False) 1 >>> percentage_traded(bm.get_df(), tm.get_df()) 0.6666666666666666