Skip to content

config_handling

mainsequence.virtualfundbuilder.config_handling

AssetMixin

Bases: BaseObjectOrm, BasePydanticModel

filter_with_asset_class(timeout=None, *args, **kwargs) classmethod

Filters assets and returns instances with their correct asset class, looping through all DRF-paginated pages.

get_ccxt_symbol(settlement_symbol=None)

Gets the right symbol for ccxt

AssetMixinOverwrite

Bases: VFBConfigBaseModel

The Asset for evaluating the portfolio.

Attributes: symbol (str): The symbol of the asset. execution_venue_symbol (ExecutionVenueNames): The execution venue where the asset traded. Needs to match with asset universe.

AssetsConfiguration

Bases: VFBConfigBaseModel

Configuration for assets included in a portfolio.

Attributes: assets_category_unique_id (str): Unique Identifier of assets category price_type (PriceTypeNames): Type of price used for backtesting. prices_configuration (PricesConfiguration): Configuration for price data handling.

BacktestingWeightsConfig

Bases: VFBConfigBaseModel

Configuration for backtesting weights.

Attributes: rebalance_strategy_name (str): Strategy used for rebalancing. rebalance_strategy_configuration (Dict): Placeholder dict for the rebalance strategy configuration. signal_weights_name (str): Type of signal weights strategy. signal_weights_configuration (Dict): Placeholder dict for the signal weights configuration.

MarketsTimeSeries

Bases: VFBConfigBaseModel

MarketsTimeSeries based on their unique id. Used as the data sources for the prices. Values include alpaca_1d_bars, binance_1d_bars etc.

Attributes: unique_identifier (str): Identfier of the MarketsTimeSeries.

ModelList

Bases: list

Necessary for configuration

PortfolioBuildConfiguration

Bases: VFBConfigBaseModel

Main class for configuring and building a portfolio.

This class defines the configuration parameters needed for building a portfolio, including asset configurations, backtesting weights, and execution parameters.

Attributes: assets_configuration (AssetsConfiguration): Configuration details for assets. portfolio_prices_frequency (str): Frequency to upsample portoflio. Optional. backtesting_weights_configuration (BacktestingWeightsConfig): Weights configuration used for backtesting. execution_configuration (PortfolioExecutionConfiguration): Execution settings for the portfolio. valuation_asset (AssetMixin): The Asset for evaluating the portfolio.

PortfolioConfiguration

Bases: VFBConfigBaseModel

Configuration for a complete portfolio, including build configuration,
TDAG updates, and VAM settings.

This class aggregates different configurations required for the
management and operation of a portfolio.

Attributes: portfolio_build_configuration (PortfolioBuildConfiguration): Configuration for building the portfolio. portfolio_markets_configuration (PortfolioMarketsConfig): VAM execution configuration.

PortfolioExecutionConfiguration

Bases: VFBConfigBaseModel

Configuration for portfolio execution.

Attributes: commission_fee (float): Commission fee percentage.

PortfolioMarketsConfig

Bases: VFBConfigBaseModel

Configuration for Virtual Asset Management (VAM) portfolio.

Attributes: portfolio_name (str): Name of the portfolio. execution_configuration (VAMExecutionConfiguration): Execution configuration for VAM.

PricesConfiguration

Bases: VFBConfigBaseModel

Configuration for price data handling in a portfolio.

Attributes: bar_frequency_id (str): The frequency of price bars. upsample_frequency_id (str): Frequency to upsample intraday data to. intraday_bar_interpolation_rule (str): Rule for interpolating missing intraday bars. is_live (bool): Boolean flag indicating if the price feed is live. markets_time_series List[MarketsTimeSeries]: The list of markets time series.

TemplateFactory

A factory for creating template-based objects, for example, market indices.

create_market_index(index_name) staticmethod

Creates a market index portfolio object based on a predefined template configuration.

Args: index_name (str): The name of the index to create, which corresponds to a specific template configuration.

Returns: PortfolioStrategy: A PortfolioStrategy object configured according to the template.

configuration_sanitizer(configuration)

Verifies that a configuration has all the required attributes.

If auto_complete is True, missing parts of the configuration will be auto-completed when possible.

Args: configuration (dict): The configuration dictionary to sanitize. auto_complete (bool, optional): Whether to auto-complete missing parts. Defaults to False.

Returns: PortfolioConfiguration: The sanitized portfolio configuration.

replace_none_with_python_none(config)

Recursively replace all string 'None' with Python None in the given dictionary and log the path where replacements occur.

Args: config (dict): The configuration dictionary.

Returns: dict: Updated dictionary with 'None' replaced by Python None.