Resolvers
See the Message Resolution section of the Network guide for a description of
how the BatchResolver
works.
- class phantom.resolvers.Resolver(enable_tracking=False)[source]
Network message resolver.
This type is responsible for resolution processing. That is, the order in which (and any special logic therein) messages are handled in a Network.
In many cases, this type can be arbitrary since the sequence doesn’t matter (i.e. the problem is not path dependent). In other cases, however, this is not the case; e.g. processing incoming market orders in an LOB.
Implementations of this class must provide implementations of the abstract methods below.
- Parameters:
enable_tracking (
bool
) – If True, the resolver will save all messages in a time-ordered list that can be accessed withtracked_messages
.
- clear_tracked_messages()[source]
Clears any stored messages.
Useful for when incrementally processing/storing batches of tracked messages.
- Return type:
- abstract handle_push(message)[source]
Called by the resolver to handle batches of messages. Any further created messages (e.g. responses from agents) must be handled by being passed to the push method (not handle_push).
- Return type:
- abstract reset()[source]
Resets the resolver and clears any potential message queues. :rtype:
None
Note
Does not clear any tracked messages.
- class phantom.resolvers.BatchResolver(enable_tracking=False, round_limit=None, shuffle_batches=False)[source]
Resolver that handles messages in multiple discrete rounds. Each round, all agents have the opportunity to respond to previously received messages with new messages. These messages are held in a queue until all agents have been processed before being consumed in the next round. Messages for each agent are delivered in a batch, allowing the recipient agent to decide how to handle the messages within the batch.
- Parameters:
enable_tracking (
bool
) – If True, the resolver will save all messages in a time-ordered list that can be accessed withtracked_messages
.round_limit (
Optional
[int
]) – The maximum number of rounds of messages to resolve. If the limit is reached an exception will be thrown. By default the resolver will keep resolving until no more messages are sent.shuffle_batches (
bool
) – If True, the order in which messages for a particular recipient are sent to the recipient will be randomised.
- clear_tracked_messages()
Clears any stored messages.
Useful for when incrementally processing/storing batches of tracked messages.
- Return type:
- handle_push(message)[source]
Called by the resolver to handle batches of messages. Any further created messages (e.g. responses from agents) must be handled by being passed to the push method (not handle_push).
- Return type:
- reset()[source]
Resets the resolver and clears any potential message queues. :rtype:
None
Note
Does not clear any tracked messages.