modular_trader.framework.portfolio_construction#

Submodules#

Classes#

BasePortfolioConstruction

Base class for portfolio construction.

EqualWeightPortfolioConstruction

Assigns equal weight to all signals. Liquidates positions no longer in signals.

Package Contents#

class modular_trader.framework.portfolio_construction.BasePortfolioConstruction#

Bases: abc.ABC

Inheritance diagram of modular_trader.framework.portfolio_construction.BasePortfolioConstruction

Base class for portfolio construction.

This class defines the interface for all portfolio construction strategies.

The __call__ method is called by the framework to construct the portfolio. It is expected to clear the current allocations and add the new allocations.

The run method is called by __call__ to perform the portfolio construction. It must be implemented by subclasses to return an iterable of Allocation objects.

__call__(context: modular_trader.context.Context, signals: modular_trader.signal.SignalCollection) Any#
Parameters:
Return type:

Any

abstract run(context: modular_trader.context.Context, signals: modular_trader.signal.SignalCollection) collections.abc.Iterable[modular_trader.allocation.Allocation]#

Must be implemented by subclasses.

Called by __call__ to perform portfolio construction.

Parameters:
Return type:

collections.abc.Iterable[modular_trader.allocation.Allocation]

class modular_trader.framework.portfolio_construction.EqualWeightPortfolioConstruction#

Bases: modular_trader.framework.portfolio_construction.base.BasePortfolioConstruction

Inheritance diagram of modular_trader.framework.portfolio_construction.EqualWeightPortfolioConstruction

Assigns equal weight to all signals. Liquidates positions no longer in signals.

run(context: modular_trader.context.Context, signals: modular_trader.signal.SignalCollection) collections.abc.Iterable[modular_trader.allocation.Allocation]#

Must be implemented by subclasses.

Called by __call__ to perform portfolio construction.

Parameters:
Return type:

collections.abc.Iterable[modular_trader.allocation.Allocation]