Overview: Contains .csv data files for bids and asks of the form:
| Unit | Price | User |
|---|
Userentry consists of theidof a userPriceentry consists of a per-unit-price for a userUnitentry is the number of units a user wants to buy (in the case of a bidder) or sell
Example data:
-
example_ask.csv -
example_bids.csv
Overview: Contains subpackages for various markets and clearing mechanisms.
-
marketmoduleThe base market class. It supports the following methods:
a.
bid: Add one bid to the orderbookb.
bid_csv: Add a collections of bids to the orderbookc.
ask: Add one ask to the orderbookd.
ask_csv: Add a collections of asks to the orderbooke.
display: Return the entire orderbookf.
clearing: Perform market clearning. This is an abstract method.g.
plot: Plot the supply and demand curve -
orderbookmoduleThe class for all bids and asks orders. It communicates with a market to add bids/asks, display the dataframe, and plots.
-
poolmoduleThe class for the pool-based market, inherited from the
marketbase class.The clearing is performed as follows:
-
Sort the union of ask and bid prices in non-descending order.
-
Iterative over each price, compute the corresponding volume.
-
Return the price with the highest volume. Note: the resulting volume should be non-decreasing as price increases to the volume-maximizing price. Therefore, once we see the volume start to decrease, the previous price is then the target price to return.
-
-
one_sidemoduleThe class for a one sided market which supports the following auctions: (i) first-price; (ii) second-price; (iii) double and (iv) reverse.
-
bilateralmoduleThe class of bilateral markets, which supports various matching mechanisms and bargaining mechanisms.
Contains the utility functions that are used by various types of markets.
bidaskmodule: contains utility functions for clearing in pooled markets.allocationmodule: contains various resource allocation mechanism for clearing pooled markets.auctionmodule: contains different auction mechanisms for one-sided markets.matchingandbargainmodules: contains different matching and bargaining mechanisms for bilateral markets.
python3 -m marketlib.markets.poolOutput:
---- Clearing Info ----
Clearing price: 2.0
Total volume: 19
Gap: 6
---- Buyer Allocation ----
User Units Bought Price
0 3 9 2.0
1 5 10 2.0
---- Seller Allocation ----
User Units Sold Price
0 0 11 2.0
1 1 5 2.0
2 2 3 2.0