Market Classes#
Subpackages#
Submodules#
assume.markets.base_market module#
- class assume.markets.base_market.MarketMechanism(marketconfig: MarketConfig)#
Bases:
object
This class represents a market mechanism. It is different thant the MarketRole, in the way that the functionality is unrelated to mango. The MarketMechanism is embedded into the general MarketRole, which takes care of simulation concerns. In the Marketmechanism, all data needed for the clearing is present.
- all_orders: list[assume.common.market_objects.Order]#
- clear(orderbook: list[assume.common.market_objects.Order], market_products: list[assume.common.market_objects.MarketProduct])#
- marketconfig: MarketConfig#
- validate_orderbook(orderbook: list[assume.common.market_objects.Order], agent_tuple: tuple) None #
method to validate a given orderbook This is needed to check if all required fields for this mechanism are present
- validate_registration(content: RegistrationMessage, meta: MetaDict) bool #
method to validate a given registration. Used to check if a participant is eligible to bid on this market
- class assume.markets.base_market.MarketRole(marketconfig: MarketConfig)#
Bases:
MarketMechanism
,Role
This is the base class for all market roles. It implements the basic functionality of a market role, such as registering agents, clearing the market and sending the results to the database agent.
- Parameters:
marketconfig (MarketConfig) – The configuration of the market
- async clear_market(market_products: list[assume.common.market_objects.MarketProduct])#
This method clears the market and sends the results to the database agent.
- Parameters:
market_products (list[MarketProduct]) – The products to be traded
- handle_data_request(content: DataRequestMessage, meta: MetaDict)#
- handle_get_unmatched(content: dict, meta: MetaDict)#
A handler which sends the orderbook with unmatched orders to an agent. Allows to query a subset of the orderbook.
- Parameters:
- Raises:
AssertionError – If the order book is invalid
- handle_orderbook(content: OrderBookMessage, meta: MetaDict)#
This method handles incoming order book messages. It validates the order book and adds it to the list of all orders.
- Parameters:
content (dict) – The content of the message
meta (any) – The metadata of the message
- Raises:
AssertionError – If the order book is invalid
- handle_registration(content: RegistrationMessage, meta: MetaDict)#
This method handles incoming registration messages. It adds the sender of the message to the list of registered agents
- Parameters:
content (dict) – The content of the message
meta (any) – The metadata of the message
- marketconfig: MarketConfig#
- async opening()#
This method is called when the market opens. It sends an opening message to all registered agents, handles scheduling the clearing of the market and the next opening.
- setup()#
This method sets up the initial configuration and subscriptions for the market role. It sets the address and agent ID of the market config to match the current context.
It Defines three filter methods (accept_orderbook, accept_registration, and accept_get_unmatched) that serve as validation steps for different types of incoming messages.
Subscribes the role to handle incoming order book messages using the handle_orderbook method. Subscribes the role to handle incoming registration messages using the handle_registration method If the market configuration supports “get unmatched” functionality, subscribes the role to handle such messages using the handle_get_unmatched
Schedules the opening() method to run at the next opening time of the market.
- async store_market_results(market_meta)#
This method sends a message to the OutputRole to update data in the database
- Parameters:
market_meta (any) – The metadata of the market
- async store_order_book(orderbook: list[assume.common.market_objects.Order])#
Sends a message to the OutputRole to update data in the database
- Parameters:
orderbook (Orderbook) – The order book to be stored