modular_trader.allocation#

Attributes#

Classes#

AllocationAdjustment

Adjust allocation by a given weight.

AllocationCollection

A collection of allocations.

AllocationTarget

A target allocation of a single asset.

Module Contents#

class modular_trader.allocation.AllocationAdjustment#

Adjust allocation by a given weight.

For example, 5% will increase allocation by 5%, while -2% will decrease allocation by 2%

Attributes:

symbol: The symbol of the asset. weight: The amount to increase or decrease the allocation by.

symbol: str#
weight: int | float#
class modular_trader.allocation.AllocationCollection#

A collection of allocations.

Attributes:

allocations: The list of allocations.

__iter__() Generator[Allocation, None, None]#

Iterate over all allocations.

Return type:

Generator[Allocation, None, None]

__len__() int#

Return the number of allocations.

Return type:

int

add(allocations: Allocation | Iterable[Allocation]) None#

Add one or more allocations to the collection.

Args:

allocations: The allocation(s) to add.

Parameters:

allocations (Allocation | Iterable[Allocation])

Return type:

None

clear() None#

Clear all allocations.

Return type:

None

remove_symbol(symbol: str)#

Remove all allocations with the given symbol.

Args:

symbol: The symbol to remove.

Parameters:

symbol (str)

allocations: list[Allocation] = None#
property symbols: set[str]#

Return all symbols in the collection.

Return type:

set[str]

class modular_trader.allocation.AllocationTarget#

A target allocation of a single asset.

Attributes:

symbol: The symbol of the asset. weight: The target weight of the asset in the portfolio.

symbol: str#
weight: int | float#
modular_trader.allocation.Allocation: TypeAlias = AllocationTarget | AllocationAdjustment#