pymarket.bids.bids module¶
-
class
pymarket.bids.bids.
BidManager
[source]¶ Bases:
object
A class used to store and manipulate a collection of all the bids in the market.
-
col_names
¶ Column names for the different attributes in the dataframe to be created. Currently and in order: quantity, price, user, buying, time, divisible.
Type: list
ofstr
-
n_bids
¶ Number of bids currently stored. Used as a unique identifier for each bid within a BidManager.
Type: int
-
add_bid
(quantity, price, user, buying=True, time=0, divisible=True)[source]¶ Appends a bid to the bid list
Parameters: - quantity (float) – Quantity of good desired. If divisible=True then any fraction of the good is an acceptable outcome of the market.
- price (float) – Uniform price offered in the market for each unit of the the good.
- user (int) – Identifier of the user submitting the bid.
- buying (bool) – True if the bid is for buying the good and False`otherwise. Default is `True.
- time (float) – Instant at which the offer was made. This is relevant only if the market mechanism has perferences for earlier bids. Default is 0
- divisible (bool) – True is the user accepts a fraction of the asked quantity as a result and False otherwise.
Returns: Unique identifier of the added bid.
Return type: Examples
>>> bm = pm.BidManager() >>> bm.add_bid(2, 1, 0) 0
-
col_names
= ['quantity', 'price', 'user', 'buying', 'time', 'divisible']
-
get_df
()[source]¶ Creates a dataframe with the bids
Returns: Dataframe with each row a different bid and each column each of the different attributes. Return type: pd.DataFrame Examples
>>> bm = pm.BidManager() >>> bm.add_bid(2, 1, 0) 0 >>> bm.add_bid(1, 3, 1, buying=False) 1 >>> print(bm.get_df()) quantity price user buying time divisible 0 2 1 0 True 0 True 1 1 3 1 False 0 True
-