base
AccountingRule Protocol and RuleRegistry.
Classes:
-
AccountingRule–Protocol for accounting rules that generate transactions for instruments.
-
RuleRegistry–Registry of accounting rules applied to instruments.
AccountingRule
Bases: Protocol
Protocol for accounting rules that generate transactions for instruments.
Methods:
-
applies_to–Return True if this rule applies to the given instrument on the given date.
-
generate–Generate the transactions for the given instrument on the given date.
applies_to
applies_to(
instrument: Instrument,
position: Position,
context: RuleContext,
) -> bool
Return True if this rule applies to the given instrument on the given date.
generate
generate(
instrument: Instrument,
position: Position,
context: RuleContext,
) -> list[Transaction]
Generate the transactions for the given instrument on the given date.
RuleRegistry
RuleRegistry()
Registry of accounting rules applied to instruments.
Methods:
-
apply_all–Apply all applicable rules and return the combined list of transactions.
-
register–Register a rule with the registry.
apply_all
apply_all(
instrument: Instrument,
position: Position,
valuation_store: ValuationStore,
market_state: MarketState | None,
date: date,
) -> list[Transaction]
Apply all applicable rules and return the combined list of transactions.