Field Definitions and Constants#
Market data field definitions and constants.
This module provides standardized field name constants and enums to ensure type safety and prevent magic strings throughout the codebase.
- class CalculatedMetric(*values)[source]#
Bases:
StrEnumCalculated metrics that are derived from base fields.
These metrics are computed by the system and added to the dataset after the initial data load.
- LOG_RETURNS = 'c_log_returns'#
- RETURNS = 'c_returns'#
- VOLATILITY = 'c_volatility'#
- class DataPipelineKeys[source]#
Bases:
objectKeys used in data pipeline result dictionaries.
Centralise string constants so callers never rely on magic strings when accessing
DataPipelineResultfields.- PORTFOLIO_ENTITY#
Key for the portfolio entity object.
- Type:
str
- PORTFOLIO_DF#
Key for the portfolio DataFrame.
- Type:
str
- START_DATE_BACKTEST#
Key for the backtest start date.
- Type:
str
- MARKET_DATA_BUNDLE#
Key for the market data bundle.
- Type:
str
- DATA_DICT#
Key for the data dictionary.
- Type:
str
- BENCHMARK#
Key for the benchmark table.
- Type:
str
- PORTFOLIO_DICT#
Key for the portfolio weights dictionary.
- Type:
str
- EQUIVALENCE_DICT#
Key for the field equivalence mapping.
- Type:
str
- BENCHMARK = 'benchmark'#
- DATA_DICT = 'data_dict'#
- EQUIVALENCE_DICT = 'equivalence_dict'#
- MARKET_DATA_BUNDLE = 'market_data_bundle'#
- PORTFOLIO_DF = 'portfolio_df'#
- PORTFOLIO_DICT = 'portfolio_dict'#
- PORTFOLIO_ENTITY = 'portfolio_entity'#
- START_DATE_BACKTEST = 'start_date_backtest'#
- class RegisterKeys[source]#
Bases:
objectKeys used in register dictionaries.
Centralise string constants for accessing register-related results produced by the engine.
- REGISTER_DF#
Key for the main register DataFrame.
- Type:
str
- COMMISSION_DF#
Key for the commissions DataFrame.
- Type:
str
- SHARES_DF#
Key for the shares DataFrame.
- Type:
str
- DAILY_WEIGHTS#
Key for the daily weights table.
- Type:
str
- ORDERS_DF#
Key for the orders DataFrame.
- Type:
str
- FINAL_TOTAL_PORTFOLIO_VALUE#
Key for the final portfolio value.
- Type:
str
- TOTAL_COMMISSIONS#
Key for total commissions paid.
- Type:
str
- YEARS#
Key for the number of years in the backtest.
- Type:
str
- PORTFOLIO_STATS#
Key for portfolio statistics.
- Type:
str
- BENCHMARK_STATS#
Key for benchmark statistics.
- Type:
str
- BENCHMARK_STATS = 'benchmark_stats'#
- COMMISSION_DF = 'Commission_df'#
- DAILY_WEIGHTS = 'Daily_Weights'#
- FINAL_TOTAL_PORTFOLIO_VALUE = 'final_total_portfolio_value'#
- ORDERS_DF = 'orders_df'#
- PORTFOLIO_STATS = 'portfolio_stats'#
- REGISTER_DF = 'Register_df'#
- SHARES_DF = 'Shares_df'#
- TOTAL_COMMISSIONS = 'Total_commissions'#
- YEARS = 'years'#
- class StandardField(*values)[source]#
Bases:
StrEnumStandard field names used internally by the engine.
These are the canonical field names that the system uses for all operations. All input data is mapped to these standard field names.
- PRICE#
Price column used for asset valuation and return calculation.
- DATE#
Column containing the trading dates.
- DATE = 'date_column'#
- PRICE = 'price_column'#
- classmethod get_all_fields() list[StandardField][source]#
Return all required standard fields including date.
- classmethod get_numeric_fields() list[StandardField][source]#
Return all numeric standard fields (exclude date).