config ====== .. py:module:: config Classes ------- .. autoapisummary:: config.ProjectPath config.DataSourceType config.FeatureConfig config.DataRequests config.DataConfig config.RewardConfig config.TradeMode config.PortfolioConfig config.StockEnv config.AgentConfig config.AnalysisConfig config.BackTestConfig config.RRConfig Module Contents --------------- .. py:class:: ProjectPath(/, **data) Bases: :py:obj:`pydantic.BaseModel` Path-like object for using variable based absolute paths .. py:attribute:: PROJECT_ROOT :type: ClassVar[pathlib.Path] .. py:attribute:: OUT_DIR :type: ClassVar[pathlib.Path | None] :value: None .. py:attribute:: BACKTEST_DIR :type: ClassVar[pathlib.Path | None] :value: None .. py:attribute:: VERSION :type: ClassVar[str] :value: '' .. py:attribute:: ACTIVE_UUID :type: ClassVar[uuid.UUID | None] :value: None .. py:attribute:: path :type: str :value: None .. py:method:: use_cache() :classmethod: .. py:method:: cache() :classmethod: .. py:method:: validate_path(data) :classmethod: .. py:method:: __str__() .. py:method:: as_path() .. py:class:: DataSourceType Bases: :py:obj:`str`, :py:obj:`enum.Enum` Enum for data source types. .. py:attribute:: ALPACA :value: 'alpaca' .. py:class:: FeatureConfig(/, **data) Bases: :py:obj:`pydantic.BaseModel` Configuration for features used in the algorithm. .. py:method:: parse_features(data) :classmethod: .. py:attribute:: features :type: List[trading.src.features.generic_features.Feature] :value: None .. py:attribute:: fill_strategy :type: str :value: None .. py:method:: __repr__() .. py:class:: DataRequests(/, **data) Bases: :py:obj:`pydantic.BaseModel` Individual Data Request .. py:attribute:: dataset_name :type: str :value: None .. py:attribute:: source :type: DataSourceType :value: None .. py:attribute:: endpoint :type: str :value: None .. py:attribute:: kwargs :type: Dict[str, Any] :value: None .. py:class:: DataConfig(/, **data) Bases: :py:obj:`pydantic.BaseModel` Configuration for data used in the algorithm. .. py:attribute:: start_date :type: str :value: None .. py:attribute:: end_date :type: str :value: None .. py:attribute:: time_step_unit :type: alpaca.data.timeframe.TimeFrameUnit :value: None .. py:attribute:: time_step_period :type: int :value: None .. py:attribute:: cache_path :type: ProjectPath :value: None .. py:attribute:: cache_enabled :type: bool :value: None .. py:attribute:: requests :type: List[DataRequests] :value: None .. py:attribute:: validation_split :type: float :value: None .. py:method:: validate_time_step_unit(value) :classmethod: Validate the time_step_unit field to ensure it is a valid TimeFrameUnit. .. py:class:: RewardConfig(/, **data) Bases: :py:obj:`pydantic.BaseModel` Configuration for the reward function used in the trading environment. .. py:attribute:: type :type: str :value: None .. py:attribute:: reward_scaling :type: float :value: None .. py:attribute:: kwargs :type: Dict[str, Any] :value: None .. py:class:: TradeMode Bases: :py:obj:`str`, :py:obj:`enum.Enum` Enum for trade modes. .. py:attribute:: DISCRETE :value: 'discrete' .. py:attribute:: CONTINUOUS :value: 'cont' .. py:class:: PortfolioConfig(/, **data) Bases: :py:obj:`pydantic.BaseModel` !!! abstract "Usage Documentation" [Models](../concepts/models.md) A base class for creating Pydantic models. .. attribute:: __class_vars__ The names of the class variables defined on the model. .. attribute:: __private_attributes__ Metadata about the private attributes of the model. .. attribute:: __signature__ The synthesized `__init__` [`Signature`][inspect.Signature] of the model. .. attribute:: __pydantic_complete__ Whether model building is completed, or if there are still undefined fields. .. attribute:: __pydantic_core_schema__ The core schema of the model. .. attribute:: __pydantic_custom_init__ Whether the model has a custom `__init__` function. .. attribute:: __pydantic_decorators__ Metadata containing the decorators defined on the model. This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1. .. attribute:: __pydantic_generic_metadata__ Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these. .. attribute:: __pydantic_parent_namespace__ Parent namespace of the model, used for automatic rebuilding of models. .. attribute:: __pydantic_post_init__ The name of the post-init method for the model, if defined. .. attribute:: __pydantic_root_model__ Whether the model is a [`RootModel`][pydantic.root_model.RootModel]. .. attribute:: __pydantic_serializer__ The `pydantic-core` `SchemaSerializer` used to dump instances of the model. .. attribute:: __pydantic_validator__ The `pydantic-core` `SchemaValidator` used to validate instances of the model. .. attribute:: __pydantic_fields__ A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects. .. attribute:: __pydantic_computed_fields__ A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects. .. attribute:: __pydantic_extra__ A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra] is set to `'allow'`. .. attribute:: __pydantic_fields_set__ The names of fields explicitly set during instantiation. .. attribute:: __pydantic_private__ Values of private attributes set on the model instance. .. py:attribute:: initial_cash :type: int :value: None .. py:attribute:: maintain_history :type: bool :value: None .. py:attribute:: buy_cost_pct :type: Union[float, List[float]] :value: None .. py:attribute:: sell_cost_pct :type: Union[float, List[float]] :value: None .. py:attribute:: max_positions :type: int | None :value: None .. py:attribute:: trade_mode :type: TradeMode :value: None .. py:attribute:: trade_limit_percent :type: float :value: None .. py:attribute:: hmax :type: float :value: None .. py:attribute:: action_threshold :type: float :value: None .. py:attribute:: max_exposure :type: float :value: None .. py:class:: StockEnv(/, **data) Bases: :py:obj:`pydantic.BaseModel` !!! abstract "Usage Documentation" [Models](../concepts/models.md) A base class for creating Pydantic models. .. attribute:: __class_vars__ The names of the class variables defined on the model. .. attribute:: __private_attributes__ Metadata about the private attributes of the model. .. attribute:: __signature__ The synthesized `__init__` [`Signature`][inspect.Signature] of the model. .. attribute:: __pydantic_complete__ Whether model building is completed, or if there are still undefined fields. .. attribute:: __pydantic_core_schema__ The core schema of the model. .. attribute:: __pydantic_custom_init__ Whether the model has a custom `__init__` function. .. attribute:: __pydantic_decorators__ Metadata containing the decorators defined on the model. This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1. .. attribute:: __pydantic_generic_metadata__ Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these. .. attribute:: __pydantic_parent_namespace__ Parent namespace of the model, used for automatic rebuilding of models. .. attribute:: __pydantic_post_init__ The name of the post-init method for the model, if defined. .. attribute:: __pydantic_root_model__ Whether the model is a [`RootModel`][pydantic.root_model.RootModel]. .. attribute:: __pydantic_serializer__ The `pydantic-core` `SchemaSerializer` used to dump instances of the model. .. attribute:: __pydantic_validator__ The `pydantic-core` `SchemaValidator` used to validate instances of the model. .. attribute:: __pydantic_fields__ A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects. .. attribute:: __pydantic_computed_fields__ A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects. .. attribute:: __pydantic_extra__ A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra] is set to `'allow'`. .. attribute:: __pydantic_fields_set__ The names of fields explicitly set during instantiation. .. attribute:: __pydantic_private__ Values of private attributes set on the model instance. .. py:attribute:: turbulence_threshold :type: float | None :value: None .. py:attribute:: reward_config :type: RewardConfig :value: None .. py:attribute:: portfolio_config :type: PortfolioConfig :value: None .. py:attribute:: lookback_window :type: int :value: None .. py:class:: AgentConfig(/, **data) Bases: :py:obj:`pydantic.BaseModel` Configuration for the agent used in the algorithm. .. py:attribute:: algo :type: str :value: None .. py:attribute:: save_path :type: ProjectPath :value: None .. py:attribute:: deterministic :type: bool :value: None .. py:attribute:: total_timesteps :type: int :value: None .. py:attribute:: kwargs :type: Dict[str, Any] :value: None .. py:class:: AnalysisConfig(/, **data) Bases: :py:obj:`pydantic.BaseModel` Configuration for the analysis of backtest results. .. py:attribute:: render_plots :type: bool :value: None .. py:attribute:: save_plots :type: bool :value: None .. py:attribute:: to_csv :type: bool :value: None .. py:attribute:: tickers :type: List[str] | None :value: None .. py:class:: BackTestConfig(/, **data) Bases: :py:obj:`pydantic.BaseModel` Configuration for backtesting the algorithm. .. py:attribute:: save_results :type: bool :value: None .. py:attribute:: backtest_dir :type: ProjectPath :value: None .. py:attribute:: analysis_config :type: AnalysisConfig :value: None .. py:method:: validate_backtest_dir(value) :classmethod: .. py:attribute:: results_path :type: ProjectPath :value: None .. py:class:: RRConfig(/, **data) Bases: :py:obj:`pydantic.BaseModel` Configuration for the algorithm. .. py:attribute:: name :type: str :value: None .. py:attribute:: description :type: str :value: None .. py:attribute:: version :type: str :value: None .. py:attribute:: out_dir :type: ProjectPath :value: None .. py:attribute:: agent_config :type: AgentConfig :value: None .. py:attribute:: data_config :type: DataConfig :value: None .. py:attribute:: feature_config :type: FeatureConfig :value: None .. py:attribute:: stock_env :type: StockEnv :value: None .. py:attribute:: backtest_config :type: BackTestConfig :value: None .. py:method:: validate_version(value) :classmethod: .. py:method:: validate_out_dir(value) :classmethod: .. py:method:: validate_config(value, info) :classmethod: